以下に示すように、プロパティファイルのロードを構成しました(Spring 3.1)
私の春のxml
<context:component-scan base-package="com.mypackage"/>
<context:property-placeholder location="file:///C:/temp/application.properties"/>
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/my-spring-xml
</param-value>
</context-param>
アプリケーションのプロパティ
expirationOffset = 777
私のJavaクラスでは、次のようにプロパティを宣言しました:
private @Value("${expirationOffset}") String propertyValue;
何らかの理由で値が初期化されていません。次のステートメントを実行すると:
System.out.println("VALUE - " + propertyValue);
出力は常に
16:03:02,355 INFO [stdout] (http--127.0.0.1-8080-1) VALUE - ${expirationOffset}
プロパティファイルをwarファイルに移動して、クラスパスにある間にアクセスしようとしましたが、それでも同じ問題です。クラスパスからアクセスする方法は次のとおりです。
<context:property-placeholder location="classpath:/conf/application.properties"/>
単純なプロパティの変更のために war ファイルを再構築する必要がないため、プロパティ ファイルを war ファイルの外に保持するのが理想的です。
私は何かを逃しましたか?
編集
このコンテキストから msm-spring.xml 初期化パラメーターを削除しました。
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/my-spring-xml
</param-value>
</context-param>
以下に示すように、それをサーブレットコンテキストに移動しました。
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>myservice</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/my-spring-xml
</param-value>
</init-param>
</servlet>
正しい値を取得しているため、上記の変更は修正されたようです。私が元々持っていた方法は、アプリケーションコンテキストでそれを持っていたということでした。つまり、アプリケーション/webapp全体で利用できるようになるということでした。
上記の 3 つのいずれかに msm-spring を使用することの違いは何ですか?