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" />