【发布时间】:2014-04-16 02:49:15
【问题描述】:
我遇到需要在系统中使用两个属性文件的情况。
-
系统属性
key.supportiveFile=C:\keypath\supportive.properties这个key path可以在classpath之外。我想为 Supportive.properties 作为 System.properties 中的键。 support.properties 文件有
-
supportive.properties。
Supportive.properties 具有键 key1 和 key2。 supportive.properties 文件中的属性必须与上下文一起加载。
理想情况下,我的属性文件将如下所示。
supportive.properties
key1=value1
key2=value2
在 spring.xml 中,我尝试加载 support.properties 并注入 spring.xml 中定义的 key1 和 key2 值,如下所示。
我。加载属性文件
<context:property-placeholder location="classpath:System.properties,file:${key.supportiveFile}"/>
二。这是一个示例 bean,我想如何将我的密钥注入 bean。
<bean id="helloWorldBean" class="com.sample.snippets.enterprise.services.HelloWorld">
<property name="prefixProp" value="${key1}" />
<property name="suffixProp" value="${key2}" />
</bean>
服务器日志显示 Could not resolve placeholder 'key.supportiveFile' in [file:${key.supportiveFile}],但它失败并且没有加载 support.property 文件。
请告知如何从技术上解决此问题。
【问题讨论】:
-
请使用正确的文本格式!