spring - Spring - 类路径资源X无法打开,因为它不存在
问题描述
我有一个我无法解决的问题!我用谷歌搜索了几个小时,但我没有找到任何解决方案......我有这个:
以及加载此 xml 资源 (consumerContext.xml) 的文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
<!-- Inclusion d'autres fichiers de contexte Spring -->
<import resource="classpath:/org/example/demo/ticket/consumer/consumerContext.xml" />
<import resource="classpath:/org/example/demo/ticket/business/businessContext.xml" />
<import resource="classpath:/org/example/demo/ticket/webapp/webappContext.xml" />
</beans>
我正在使用 Maven 并且 src/main/resources 在类路径中。
我总是并且总是错误:
class path resource [org/example/demo/ticket/consumer/consumerContext.xml] cannot be opened because it does not exist
有人有想法吗?
感谢提前(对不起我的英语......)
解决方案
我认为问题在于,您没有将 consumerContext.xml 放在 org/example/demo/ticket/consumer/ 中。
要解决这个问题:
1)将consumerContext.xml和其他xml直接放在src/resources
2) 改变
<import resource="classpath:/org/example/demo/ticket/consumer/consumerContext.xml" />
至
<import resource="classpath:consumerContext.xml" />
推荐阅读
- nginx - GKE 中的 Kubernetes - Nginx Ingress 部署 - 分配给 Ingress 资源的公共 IP
- c# - 如何将 BigQuery 时间戳转换为 DateTime?
- php - 尝试更新时的laravel验证错误
- json - 使用 Newtonsoft JSON 和 VB.NET 检查嵌套 JSON 元素中是否存在键
- ios - 具有动态高度的 UITableViewCell 中的 UITableView
- mongodb - Kubernetes MongoDB 自动缩放
- excel - 如何判断是一个月的第一天还是第二天?
- javascript - 如何在另一种方法中检索一些变量
- java - 在 Java VisualVM 中安装 Visual GC 后出现 java.lang.NoClassDefFoundError
- android - 更改 Android Emulator 麦克风的默认设置