2016-04-20 64 views
0

我试图使用Spring的@PropertySource注解加载属性文件。属性文件存储在Wildfly 8模块中。我得到的错误消息是:Spring 3 @PropertySource在Wildfly 8模块中找不到属性文件

class path resource [campaigner.properties] cannot be opened because it does not exist 

以下是应用程序服务使用的Java代码。

@Configuration 
@PropertySource("classpath:campaigner.properties") 
class ServiceConfigImpl implements ServiceConfig 
{ 
    @Autowired 
    private Environment env; 

    @Bean(name = "serviceConfig") 
    public ServiceConfig getServiceConfig() 
    { 
    return new ServiceConfigImpl(this.env); 
    } 
} 

这是我放在我的.ear文件的META-INF目录下的jboss-deployment-structure.xml。

<jboss-deployment-structure> 
    <deployment> 
    <dependencies> 
     <module name="com.dr_dee_sw.campaigner" /> 
    </dependencies> 
    </deployment> 
</jboss-deployment-structure> 

我还放了MANIFEST.MF文件中META-INF目录

Manifest-Version: 1.0 
Ant-Version: Apache Ant 1.9.4 
Created-By: 1.7.0_71-b14 (Oracle Corporation) 
Dependencies: com.dr_dee_sw.campaigner 

这是我的模块文件,我已经把WILDFLY_HOME \模块\ COM \ dr_dee_sw \活动家\主目录以及campaigner.properties文件

<module xmlns="urn:jboss:module:1.1" name="com.dr_dee_sw.campaigner"> 
    <resources> 
    <resource-root path="."/> 
    </resources> 
</module> 

我在想什么?

回答

0

这个页面让我回答:https://www.javacodegeeks.com/2012/09/jboss-as-7-classloading-explained.html。我的jboss-deployment-structure.xml是错误的。我在EAR文件中有一个EJB-JAR文件,它需要成为该文件的焦点。因此,我必须从使用<部署>到<子部署>切换,如下所示。

<jboss-deployment-structure> 
    <sub-deployment name="campaigner-service.jar"> 
    <dependencies> 
     <module name="com.dr_dee_sw.campaigner" /> 
    </dependencies> 
    </sub-deployment> 
</jboss-deployment-structure> 
相关问题