spring - 在 Spring 中添加了所有依赖项,并且 spring 配置也完成了,然后在运行时它给出了 filenotfoundexception
问题描述
File f = new File("Beans.xml");
System.out.println("Exist test: " + f.exists());
ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
我的项目结构:
解决方案
尝试以下解决方案 -
1.解决方案1:
尝试使用:new ClassPathXmlApplicationContext("classpath:beans.xml");
2.解决方案2:
尝试将 Bean.xml 文件移动到src/main/resources folder
并像这样访问它 -new ClassPathXmlApplicationContext("Beans.xml");
3.解决方案3:
在 spring-servlet.xml 中输入 -
<import resource="classpath*:Beans.xml" />
推荐阅读
- android - 如何在 react-native 中缩小 WebView?
- javascript - 将图像设置为页面在 React 中呈现的第一张图像
- sas - 手动和由 SAS 完成时的卡方检验结果差异
- reactjs - 模拟 textarea Jest 测试的更改
- opengl - 将递归渲染的场景显示到平面中
- sql - 数据类型等效项:MS Access 表 ↔ 'CREATE TABLE' 查询 ↔ ODBC SQL
- java - 使用 switch 语句设置对象变量
- vb.net - 作为图形对象的球和曲线之间的碰撞
- php - PHP包括在错误的地方搜索
- python - OSX swift no module named 6