我有一个Spring 3.1应用程序。假设它具有包含以下内容的XML:
<context:property-placeholder location="classpath:somename.properties" />
<context:property-placeholder location="classpath:xxx.properties" />
Run Code Online (Sandbox Code Playgroud)
我希望始终加载some.properties(假设它存在),但是第二个占位符的xxx部分将根据活动的配置文件用某些名称替换。我已经试过了:
<beans profile="xx1">
<context:property-placeholder location="classpath:xx1.properties" />
</beans>
<beans profile="xx2">
<context:property-placeholder location="classpath:xx2.properties" />
</beans>
Run Code Online (Sandbox Code Playgroud)
此外,两个文件的属性均具有相同的键,但值不同。
但是它没有用,因为某些后来的Bean具有一个属性的占位符,该属性的键在xx1.properties(和xx2.properties)中定义,因此Spring抱怨说在应用程序上下文中找不到该键。