一、问题描述
项目开发使用的是SSM框架,项目那个正常运行,开发一个新功能后,添加了一些配置文件,再重新运行项目抛出异常,找不到name为init的bean。
二、异常信息详细
六月 30, 2018 8:49:56 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [springServlet] in context with path [/cyd_online] threw exception [Handler processing failed; nested exception is java.lang.ExceptionInInitializerError] with root cause
java.util.MissingResourceException: Can't find bundle for base name init, locale zh_CN
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:773)
at com.cyd.modules.cyd.fuiou.utils.ConfigReader.<clinit>(ConfigReader.java:11)
at com.cyd.modules.cyd.fuiou.base.Constants.<clinit>(Constants.java:55)
at com.cyd.modules.cyd.fuiou.service.NewProOrderService.order(NewProOrderService.java:79)
at com.cyd.modules.cyd.service.AccountRechargeService.getNewProOrder(AccountRechargeService.java:86)
at com.cyd.modules.cyd.service.AccountRechargeService$$FastClassBySpringCGLIB$$ce1e5ee.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
...
...
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.MissingResourceException: Can't find bundle for base name init, locale zh_CN
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:773)
at com.cyd.modules.cyd.fuiou.utils.ConfigReader.<clinit>(ConfigReader.java:11)
... 55 more
三、问题处理
此处的问题,是因为配置文件init.properties放在了开发模块fuiou下,而bean的路径资源路径是classpath:/init.properties,导致项目运行时加载不到给配置文件而无法初始实例化bean。
此处将配置文件init.properties放在跟资源目录下即可。