Java 使用Jboss读取PropertyPlaceHolderConfigure类路径Spring

Java 使用Jboss读取PropertyPlaceHolderConfigure类路径Spring,java,spring,jboss,Java,Spring,Jboss,使用PropertyPlaceHolderConfigure将spring配置外部化 财产 将以下代码添加到springservlet.xml <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>classpath:environment.prop

使用
PropertyPlaceHolderConfigure
将spring配置外部化 财产

将以下代码添加到
springservlet.xml

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
     <property name="location">
         <value>classpath:environment.properties</value>
     </property>
  </bean> 
过滤器
值存在于
环境中。属性

environment.properties
文件存在于Jboss模块中,可以使用资源包从代码中读取

但是,由于这些更改,属性文件无法加载,并且在发布代码时抛出以下错误

原因:java.lang.IllegalArgumentException:无法解析 字符串值“${filter}”中的占位符“filter”

附言:


还尝试将路径硬编码为
文件:${jboss.home.dir}/modules/system/layers/base/configuration/main/environment.properties
,但似乎不起作用

我认为您的问题在于您的
spring servlet.xml
没有链接到您的
spring security.xml
。因此,
spring security.xml
不了解
属性placeholderconfigure

在我看来,您应该在
properties context.xml
中配置
propertyplaceholderconfigure
(例如),这样您就可以
将这个新文件导入
spring servlet.xml
spring security.xml
,如下所示:

<import resource="classpath:properties-context.xml" />

<import resource="classpath:properties-context.xml" />