我遇到需要在我的系統中使用兩個屬性文件的情況。正在加載上下文時加載屬性文件,將文件路徑作爲另一個屬性文件的屬性
System.properties
key.supportiveFile=C:\keypath\supportive.properties
這關鍵路徑其可以是類路徑之外。我想維護支持.properties作爲System.properties中的鍵的路徑。 supportive.properties文件有
supportive.properties。
Supportive.properties具有密鑰key1,key2。 屬性supportive.properties文件必須使用上下文加載。
理想情況下,我的屬性文件將顯示如下。
supportive.properties
key1=value1
key2=value2
在spring.xml我試圖加載supportive.properties和注入KEY1和KEY2值在spring.xml定義像的下方。
i。加載屬性文件
<context:property-placeholder location="classpath:System.properties,file:${key.supportiveFile}"/>
ii。這是一個示例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}]
但失敗並不會加載supportive.property文件。
請告知如何解決這個技術問題。
請使用正確的文本格式! – Baby