提示:
日志打印Loading XML bean definitions from class path resource [applicationContext.xml]一般是获取applicationContext.xml失败。
例:
applicationContext.xml所在位置如下(左),service写一个save()方法。applicationContext.xml配置内容省略…
写个@Test测试类通过ClassPathXmlApplicationContext获取spring的配置文件applicationContext.xml 。
[org.springframework.beans.factory.xml.XmlBeanDefinitionReader]-[INFO] Loading XML bean definitions from class path resource [applicationContext.xml]
全部日志:
2019-12-19 14:53:32,285 [main] [org.springframework.core.env.StandardEnvironment]-[DEBUG] Adding [systemProperties] PropertySource with lowest search precedence
2019-12-19 14:53:32,289 [main] [org.springframework.core.env.StandardEnvironment]-[DEBUG] Adding [systemEnvironment] PropertySource with lowest search precedence
2019-12-19 14:53:32,289 [main] [org.springframework.core.env.StandardEnvironment]-[DEBUG] Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2019-12-19 14:53:32,293 [main] [org.springframework.context.support.ClassPathXmlApplicationContext]-[INFO] Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@40b73194: startup date [Thu Dec 19 14:53:32 CST 2019]; root of context hierarchy
2019-12-19 14:53:32,346 [main] [org.springframework.core.env.StandardEnvironment]-[DEBUG] Adding [systemProperties] PropertySource with lowest search precedence
2019-12-19 14:53:32,346 [main] [org.springframework.core.env.StandardEnvironment]-[DEBUG] Adding [systemEnvironment] PropertySource with lowest search precedence
2019-12-19 14:53:32,347 [main] [org.springframework.core.env.StandardEnvironment]-[DEBUG] Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
2019-12-19 14:53:32,369 [main] [org.springframework.beans.factory.xml.XmlBeanDefinitionReader]-[INFO] Loading XML bean definitions from class path resource [applicationContext.xml]
我这运行失败原因是: applicationContext.xml放在src/main/resources/spring 目录下,获取applicationContext.xml配置文件的时候前边没有加spring目录。加上spring/后项目正常运行了。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/15952.html