关于applicationContext.xml cannot be opened because it does not exist的解决
2016-09-29 16:21
471 查看
ApplicationContext 对象的初始化的时候,根据配置文件的位置,找到配置文件,然后初始化,
但是吧,老是出错,总是分不清用哪个去初始化。
下面简单总结下:
1.ClassPathXmlApplicationContext
加上file:把路径写全(用这个方法xml可以放任意地方)
ApplicationContext ctx = new ClassPathXmlApplicationContext("file:E:/fusion/intellij_work/TrunkNew/sss.xml");
2.FileSystemXmlApplicationContext
估计相对的是项目的目录位置
ApplicationContext ctx = new FileSystemXmlApplicationContext("sss.xml");//这个时候sss.xml是在项目的根目录下
ApplicationContext ctx = new FileSystemXmlApplicationContext("src/sss.xml");//这个时候sss.xml是在项目的根目录下的src文件夹下
但是吧,老是出错,总是分不清用哪个去初始化。
下面简单总结下:
1.ClassPathXmlApplicationContext
加上file:把路径写全(用这个方法xml可以放任意地方)
ApplicationContext ctx = new ClassPathXmlApplicationContext("file:E:/fusion/intellij_work/TrunkNew/sss.xml");
2.FileSystemXmlApplicationContext
估计相对的是项目的目录位置
ApplicationContext ctx = new FileSystemXmlApplicationContext("sss.xml");//这个时候sss.xml是在项目的根目录下
ApplicationContext ctx = new FileSystemXmlApplicationContext("src/sss.xml");//这个时候sss.xml是在项目的根目录下的src文件夹下
相关文章推荐
- 关于applicationContext.xml cannot be opened because it does not exist的解决
- 关于applicationContext.xml cannot be opened because it does not exist的解决
- 关于applicationContext.xml cannot be opened because it does not exist的解决
- 关于applicationContext.xml cannot be opened because it does not exist的解决
- 关于applicationContext.xml cannot be opened because it does not exist的解决
- 关于applicationContext.xml cannot be opened because it does not exist的解决
- applicationContext.xml cannot be opened because it does not exist的解决方法
- 关于class path resource [applicationContext.xml] cannot be opened because it does not exist
- class path resource [applicationContext.xml] cannot be opened because it does not exist
- 关于spring-servlet.xml cannot be opened because it does not exist的解决
- applicationContext.xml cannot be opened because it does not exist
- idea class path resource [applicationContext.xml] cannot be opened because it does not exist
- class path resource [spring/applicationContext.xml] cannot be opened because it does not exist
- class path resource [applicationContext.xml] cannot be opened because it does not exist
- 创建spring的IOC容器时[ApplicationContext.xml] cannot be opened because it does not exist
- 关于spring-servlet.xml cannot be opened because it does not exist的解决
- 创建spring的IOC容器时[ApplicationContext.xml] cannot be opened because it does not exist
- eclipse项目报错怎么解决class path resource [beans.xml] cannot be opened because it does not exist
- java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist 解决方法
- java.io.FileNotFoundException: [WEB-INF/spring-servlet.xml] cannot be opened because it does not exist