Java Spring局部和系统属性
只有在未设置系统属性(来自操作系统)的情况下,才能在spring中使用本地属性(在applicationContext.xml中声明)。现在,本地属性覆盖了所有系统属性。我希望系统属性的优先级更高 我从操作系统中设置的文件和系统属性导入本地属性:Java Spring局部和系统属性,java,spring,properties,Java,Spring,Properties,只有在未设置系统属性(来自操作系统)的情况下,才能在spring中使用本地属性(在applicationContext.xml中声明)。现在,本地属性覆盖了所有系统属性。我希望系统属性的优先级更高 我从操作系统中设置的文件和系统属性导入本地属性: 我无法实现自定义PropertyPlaceholders。一种方法是将它们分成两部分并使用顺序 <context:property-placeholder location="classpath*:*.properties" ignor
我无法实现自定义PropertyPlaceholders。一种方法是将它们分成两部分并使用顺序
<context:property-placeholder
location="classpath*:*.properties"
ignore-resource-not-found="true"
ignore-unresolvable="true"
order ="0" />
<context:property-placeholder
location="file:/var/myfolder/local.properties"
ignore-resource-not-found="true"
ignore-unresolvable="true"
order="-1"/>
最低顺序优先所以如果我做对了,你不会把它们放在本地吗? 更新 您还可以在systemPropertiesMode元素中使用system\u properties\u mode\u override i blv,这不是您想要的吗(来自
PropertyPlaceHolderConfigure
api)
你应该加上这个
<property name="searchSystemEnvironment" value="true"/>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
到您的占位符配置器操作系统中设置的系统属性。我无法执行此操作。这是一个真正的大型遗留项目。这很难解释。很抱歉
<property name="searchSystemEnvironment" value="true"/>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>