找不到Spring配置文件路径问题
初学Spring在使用ApplicationContext appCon = new ClassPathXmlApplicationContext("applicationContext.xml");遇到的问题:

许多教程和书上都是说把applicationContext.xml或beans.xml放到src的目录下即可,但就会出现如上问题。
解决方案
由于ClassPathXmlApplicationContext是在当前路径进行寻找,所以要将applicationContext.xml或beans.xml放到当前运行文件的同一目录下,就可以解决该问题。

附上Spring的配置文件,方便以后取用
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">

浙公网安备 33010602011771号