spring - 在类路径中找不到属性文件 - 部署 EAR 时出错

标签 spring eclipse maven gradle jboss7.x

尝试在 JBoss AS 7 中部署 EAR 项目时出现以下错误。
(MSC 服务线程 1-5) 上下文初始化失败。 java.io.FileNotFoundException:类路径资源 [.properties] 无法打开,因为它不存在

下面给出了更详细的错误快照。

16:20:08,548 ERROR [org.springframework.web.servlet.DispatcherServlet]
(MSC service thread 1-5) Context initialization failed:
org.springframework.beans.factory.BeanDefinitionStoreException: 
Failed to parse configuration class [xx.xx.Config]; nested exception
is java.io.FileNotFoundException: class path resource
[wwwr.properties] cannot be opened because it does not exist at
org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181)
[spring-context-4.2.1.RELEASE.jar:4.2.1.RELEASE]  Caused by:
java.io.FileNotFoundException: class path resource [wwwr.properties]
cannot be opened because it does not exist



16:20:08,588 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/MyWeb]]
(MSC service thread 1-5)  StandardWrapper.Throwable:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed
to parse configuration class [com.xx.Config];  nested exception is
java.io.FileNotFoundException: class path resource [wwwr.properties]
cannot be opened because it does not exist

我使用 JBoss AS7 服务器和 MyEclipse 作为 IDE。

最佳答案

好吧,我发现解决方案涉及以下步骤

1)确保属性文件在所涉及项目的类路径中,或者至少在Jboss中部署的模块中。
1- a) 验证 modules.xml 文件是否有正确的条目

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.xx.yy">
<resources>
<resource-root path="./properties/"/>

2) 验证 EAR 中的 Manifest.mf 文件是否具有所需的依赖项。
Dependencies: com.xx.yy

3)清理构建并部署到服务器。

关于spring - 在类路径中找不到属性文件 - 部署 EAR 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52414705/

相关文章:

java - mvn 包因新的 SpringBoot 项目而失败

java - 将应用程序与 spring 社交网站集成

java - 如何从 Spring 环境自动生成 postman 集合

eclipse - m2eclipse 和 Eclipse WTP

java - Icefaces 2 插件问题

eclipse - 如何修复错误 : test source folder 'src/test/java' in project must have an output folder that is not also used for main source"?

java - 另一台服务器上的 Spring Boot 外部配置

java - 如何将通用类型作为交换输入主体而不是强制转换?

eclipse - 如何在 Eclipse 中打开 emacs 键?

Javax Jersey 客户端处理异常