私のアプリケーションは、Spring 2.5.6、Richfaces 3.1.6.SR1、JSF 1.1_02 を搭載した Jboss 4.2.2 GA で実行されています。私が欲しいのは、s.th. お気に入り
- information1="ジョーイ"
- information2="ディーディー"
- information3="マーキー"
- [...]
このファイルを変更すると、すぐに反映されます。私はこのように始めました:
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
[...]
PropertiesConfiguration configure = null;
{
try {
configure = new PropertiesConfiguration("myProperties.properties");
configure.setReloadingStrategy(new FileChangedReloadingStrategy());
configure.setAutoSave(true);
} catch (ConfigurationException e) {
e.printStackTrace();
}
}
これは、myProperties.properties が耳の中のターゲット ディレクトリのどこかにある場合にのみ機能するようです。だから私は自分のコードを変更しました:
File file = new File(myAppRoot + FSEP + "appserver" + FSEP + "server" + FSEP + "default"
+ FSEP + "conf" + FSEP + "myApp" + FSEP + "myProperties.properties");
configure = new PropertiesConfiguration(file);
configure.setReloadingStrategy(new FileChangedReloadingStrategy());
configure.setAutoSave(true);
これはうまくいきます。しかし、絶対パスの使用は避けたいと思います。
<bean id="myPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
[...]
<property name="locations">
<list>
<value>classpath:myProperties.properties</value>
<value>classpath:myApp/myProperties.properties</value>
</list>
</property>