Java 如何在JBoss4.2中将外部属性文件添加到类路径

Java 如何在JBoss4.2中将外部属性文件添加到类路径,java,jboss,Java,Jboss,我想在启动JBoss4.2时读取一个外部属性文件。我想将它添加到类路径中,以便从WAR文件中读取它。我见过JBoss6使用模块的不同解决方案,但我没有见过任何与JBoss4.2相关的解决方案 我在“jboss service.xml”中包含了以下代码: <!-- Bean for reading properties --> <mbean code="org.jboss.varia.property.SystemPropertiesService"

我想在启动JBoss4.2时读取一个外部属性文件。我想将它添加到类路径中,以便从WAR文件中读取它。我见过JBoss6使用模块的不同解决方案,但我没有见过任何与JBoss4.2相关的解决方案

我在“jboss service.xml”中包含了以下代码:

    <!-- Bean for reading properties -->
    <mbean code="org.jboss.varia.property.SystemPropertiesService"      
     name="jboss.util:type=Service,name=SystemProperties">
     <!-- Load properties from each of the given comma separated URLs -->
     <attribute name="URLList">
            ./conf/path.tmview.properties
     </attribute>
    </mbean>
此属性在以下bean定义中使用

   <bean id="tmviewConfigurerLocation"   class="org.springframework.core.io.FileSystemResource">
      <constructor-arg value="${property-placeholder-filepath}" />
   </bean>
因此,属性被读取,但我一直获得以下异常

    2015-03-24 15:45:39,219 ERROR    
    [org.springframework.web.context.ContextLoader] Context 
    initialization failed
    org.springframework.beans.factory.BeanInitializationException: Could   
    not load properties; nested exception is 
    java.io.FileNotFoundException: ${property-placeholder-filepath} (The 
    system cannot find the file specified)
    at   
    org.springframework.beans.factory.config.PropertyResourceConfigurer.
    postProcessBeanFactory(PropertyResourceConfigurer.java:78)

有没有什么特殊的方法来读取Springbean中的属性

在JBoss4中,您可以将属性文件放到/server//conf目录中,它们可以从类路径中获得


另一种可能是将自定义目录添加到类路径,要执行此操作,请参见“确定”。最后,我解决了这个问题。问题似乎出在读取application-context.xml中

<bean id="propertyConfigurer"   
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
            <value>file:${tmview.conf.variables}</value>    
    </property>
</bean>

我必须添加一个属性占位符阅读器。关于jboss,您可以从conf/jboss-service.xml或deploy/properties-receive.xml读取参数文件,但从第二个文件读取似乎更合适

我试图将文件放入conf,但没有结果。添加第二个conf文件夹也是如此。
    2015-03-24 15:45:39,219 ERROR    
    [org.springframework.web.context.ContextLoader] Context 
    initialization failed
    org.springframework.beans.factory.BeanInitializationException: Could   
    not load properties; nested exception is 
    java.io.FileNotFoundException: ${property-placeholder-filepath} (The 
    system cannot find the file specified)
    at   
    org.springframework.beans.factory.config.PropertyResourceConfigurer.
    postProcessBeanFactory(PropertyResourceConfigurer.java:78)
<bean id="propertyConfigurer"   
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
            <value>file:${tmview.conf.variables}</value>    
    </property>
</bean>