Tomcat 環境にデプロイされた私の webapp には、${myurl} のような placeHolder を含む Spring 構成ファイルが 1 つあります。プレースホルダーを置き換えるために、 PropertyPlaceholderConfigurater Bean を含む WEB-INF ディレクトリに applicationContext.xml を作成し、その場所を WEB-INF ディレクトリ内のプロパティ ファイルに設定しました。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="placeHolderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="WEB-INF/my.properties"/>
</bean>
<import resource="classpath*:META-INF/springFile1.xml"/>
</beans>
次に、web.xml でコンテキストを指定します。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml
</param-value>
</context-param>
WEB-INF/my.properties 内 myurl=http://www.google.com
これは springFile1.xml です
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="placeholderPrefix" value="${" />
<property name="placeholderSuffix" value="}" />
</bean>
<bean id="mycache" class="com.abc.MyURL"
init-method="start" destroy-method="stop">
<constructor-arg value="${myurl}" />
</bean>
</beans>
解析されていない値 ${myurl} を取得し続けます
プロパティ ファイルをクラスパス、絶対パス、および WEB-INF に配置しようとしましたが、結果はすべて同じです。
助言がありますか?ありがとう。