2016-08-01 10 views
0

Spring 4.xでは、ローカル・ファイルにアクセスし、構成変数をロードするのに常にfile:#{systemProperties['user.home']}を使用しました。しかし、非常に古いプロジェクトでは、Spring 1.x(1.2.7)を使用する必要があり、同じコードが今では動作しません。私もfile:${systemProperties['user.home']}で試しましたが、何もありません。環境がプレースホルダーを解決できないようですsystemProperties(エラーが返されたセクションを参照してください)Spring 1.xでのシステム・プロパティへのアクセス

誰かが私にヒントをくれますか?

アプリケーションコンテキストエキス

<bean id="props" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 
    <property name="locations"> 
     <list> 
      <value>file:{systemProperties['user.home']}/ldap/conf/ldapconfiguration.properties</value> 
     </list> 
    </property> 
    <property name="ignoreResourceNotFound" value="false" /> 
</bean> 

エラーが発生しましたありがとうござい

Error creating bean with name 'propertyConfigurer' defined in class path resource [ApplicationContext.xml]: Cannot resolve reference to bean 'props' while setting bean property 'properties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'props' defined in class path resource [ApplicationContext.xml]: Initialization of bean failed; nested exception is java.io.FileNotFoundException: ${systemProperties['user.home']}\ldap\conf\ldapconfiguration.properties (The system cannot find the path specified) 

を返しました。智異Tousekによって提供されるように

ソリューション

<bean id="props" 
    class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 
    <property name="locations"> 
     <list> 
      <value>file:${user.home}/ldap/conf/ldapconfiguration.properties</value> 
     </list> 
    </property> 
<property name="ignoreResourceNotFound" value="false" /> 

答えて

1

あなたはPropertyPlaceholderConfigurerを使用することができます。システムプロパティをサポートすることができます。#setSystemPropertyMode()を参照してください。

+0

どうもありがとうございました!! – gioconno

関連する問題