0
私は春のプロパティファイル内の環境変数を使用しようとしているが、アプリが環境変数
export TEST_VAR=hello
myapp.propertiesを実行している
を動作するようには思えません
test.variable=${TEST_VAR}
enter code here
私がテストすると、test.variableはhelloには変換されませんが、$ {TEST_VAR}のままです。
は、どのように私は、そのファイル内からのEnv変数を得ることができますか?
私は
<bean id="props" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="singleton" value="true" />
<property name="ignoreResourceNotFound" value="false" />
<property name="locations">
<list>
<value>classpath:myapp.properties</value>
<value>file://#{systemProperties['myApp.configurationFile']}</value>
</list>
</property>
</bean>
<bean class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer">
<property name="properties" ref="props" />
</bean>
<bean id="properties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties" ref="props" />
</bean>
myApp.configurationFileはTomcatが設定]プレースホルダに追加-DmyApp.configurationFile = ...
途中で、私は顕著な問題はありません。あなたはMCVEを提供する必要があります:最小、完全、および検証可能な例。 https://stackoverflow.com/help/mcve – davidxxx
を参照してください。これは文字通り、私が春にどのように指示するのかを除いて唯一のことです。私はその投稿に追加しました。 – Paulus2