java.io.FileNotFoundException: D:\Workspaces\MyEclipse 8.5\spring\applicationContext.xml (系统找不到指定的文
来源:互联网 发布:editplus是什么软件 编辑:程序博客网 时间:2024/05/22 15:27
今天 重新写了一个spring项目发现出现这个问题:
java.io.FileNotFoundException: D:\Workspaces\MyEclipse 8.5\spring\applicationContext.xml (系统找不到指定的文件。)
解决方案:
1
a:
import org.springframework.context.support.FileSystemXmlApplicationContext;
修改为
import org.springframework.context.support.ClassPathXmlApplicationContext;
b:
ApplicationContext context=new FileSystemXmlApplicationContext("applicationContext.xml");
修改为
ApplicationContext context =new ClassPathXmlApplicationContext("applicationContext.xml");
2
spring配置文件放到classpath里,而不是WEB-INF下。
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath*:/applicationContext.xml");
究其原因:看spring api你会发现FileSystemXmlApplicationContext和ClassPathXmlApplicationContext,有不同我个人意见这就是导致不同结果的原因:
FileSystemXmlApplicationContext
Standalone XML application context, taking the context definition files from the file system or from URLs, interpreting plain paths as relative file system locations (e.g. "mydir/myfile.txt"). Useful for test harnesses as well as for standalone environments.
NOTE: Plain paths will always be interpreted as relative to the current VM working directory, even if they start with a slash. (This is consistent with the semantics in a Servlet container.)Use an explicit "file:" prefix to enforce an absolute file path.
ClassPathXmlApplicationContextStandalone XML application context, taking the context definition filesfrom the class path, interpreting plain paths as class path resource names that include the package path (e.g. "mypackage/myresource.txt"). Useful for test harnesses as well as for application contexts embedded within JARs.
希望更明白的人加以指正
- java.io.FileNotFoundException: D:\Workspaces\MyEclipse 8.5\spring\applicationContext.xml (系统找不到指定的文
- nested exception is java.io.FileNotFoundException: config.xml (系统找不到指定的文件。)
- Error:java.io.FileNotFoundException: 系统找不到指定的文件.
- java.io.FileNotFoundException: applicationContext.xml
- applicationContext.xml (系统找不到指定的文件)
- applicationContext.xml (系统找不到指定的文件)
- 启动tomcat时报错java.io.FileNotFoundException (系统找不到指定的路径。)
- Android 混淆提示 java.io.FileNotFoundException: ...\proguard-rules\release\aapt_rules.txt (系统找不到指定的路径)
- struts上传文件,报错:java.io.FileNotFoundException:(系统找不到指定的路劲)
- Android 混淆提示 java.io.FileNotFoundException: ...\proguard-rules\release\aapt_rules.txt (系统找不到指定的路径)
- java.io.FileNotFoundException: .\xxx\xxx.png (系统找不到指定的路径。)
- spring中遇到的applicationContext.xml (系统找不到指定的文件。)
- Java properties | FileNotFoundException: properties (系统找不到指定的文件。)
- 错误java.io.FileNotFoundException: Source 'E:\Workspaces\MyEclipse 8.6\.metadata\.me_tcat\work\。。
- Log4J配置后, log4j:ERROR setFile(null,true) call failed. 报错:java.io.FileNotFoundException: /log/mytest2.log (系统找不到指定的路径。)
- Spring,找不到applicationContext.xml的解决办法
- 找不到spring的applicationContext.xml异常
- Spring配置文件applicationContext.xml 找不到的问题
- 2012,最后一个暑假
- #舍得Share#Ffmpeg使用语法
- 从“手机冲浪”用户突破1亿看移动互联网未来
- paip.提升安全性--------密码控件与软键盘
- 关于UITableView的Cell复用
- java.io.FileNotFoundException: D:\Workspaces\MyEclipse 8.5\spring\applicationContext.xml (系统找不到指定的文
- 多核计算与程序设计 - 01 基础知识 之一 多核编程与单核多线程和分布式编程的区别
- paip.html调试工具--显示控件名称与值
- struts2.0工作原理
- java使用POI操作Excel报表
- 设计模式
- visualbox虚拟机(debian)互连网络配置
- 单链表反转C语言实现
- 一起读nodejs(一)----概览和全局对象(Synopsis &Global Objects)