运行项目日志提示:Loading XML bean definitions from class path resource [applicationContext.xml]

提示:

日志打印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/后项目正常运行了。

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值