org.springframework.beans.factory.BeanInitializationException: Could not load properties;
2018-01-24 14:21
666 查看
基本报错信息表现为:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/db.properties]
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:147)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:669)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5118)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/db.properties]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:140)
at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:143)
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156)
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:137)
... 15 more
可能性1:没有引入数据源
在applicationContext.xml添加数据源 (请根据自己的项目引用)
<context:property-placeholder location="classpath:db.properties"/>可能性2:引入了数据源但是找不到文件
这个问题目前我只在idea中遇到,myEclipse中没出现过。
找到项目的资源文件(resources),查看是否是这种图标
如果不是则在文件上右键→ Mark Dirextory as
将文件属性设置为 Resources Root 后重新编译项目重试(我这边已经改过了,所以在上面看不到有Resources
Root属性)
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/db.properties]
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:147)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:669)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5118)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5634)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/db.properties]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:140)
at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:143)
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156)
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:137)
... 15 more
可能性1:没有引入数据源
在applicationContext.xml添加数据源 (请根据自己的项目引用)
<context:property-placeholder location="classpath:db.properties"/>可能性2:引入了数据源但是找不到文件
这个问题目前我只在idea中遇到,myEclipse中没出现过。
找到项目的资源文件(resources),查看是否是这种图标
如果不是则在文件上右键→ Mark Dirextory as
将文件属性设置为 Resources Root 后重新编译项目重试(我这边已经改过了,所以在上面看不到有Resources
Root属性)
相关文章推荐
- org.springframework.beans.factory.BeanInitializationException: Could not load properties;
- Could not load org/springframework/beans/factory/config/Scope.class. java.util.zip.ZipException: inv
- Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: privat
- 关于SpringMVC中org.springframework.beans.factory.BeanCreationException: Could not autowire field:的问题的解决
- springBoot:Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire fi
- 个人笔记 org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.
- org.springframework.beans.factory.BeanDefinitionStoreException: Could not resolve bean definition re
- Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field
- Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field
- org.springframework.beans.factory.BeanCreationException: Could not autowire field:
- 【问题解决】 web项目启动不了 org.springframework.beans.factory.BeanCreationException: Could not autowire field:
- org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [XXXXXXXXX] for be
- 严重: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error cre
- Spring:BeanInitializationException: Could not load properties
- Initialization of bean failed; nested exception is org.springframework.beans.factory.: 错误分析
- Context initialization failed org.springframework.beans.factory.BeanCreationException:
- Java org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class
- org.springframework.beans.factory.CannotLoadBeanClassException:
- spring问题org.springframework.beans.factory.CannotLoadBeanClassException
- org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class ‘XXX’