私のアプリケーションは、Spring 2.5.6、Richfaces 3.1.6.SR1、JSF 1.1_02のJboss 4.2.2 GAで動作しています。 私がしたいのは、私の耳の外にporpertieファイルがあり、これにはs.thが含まれています。以下のようなSpringでのPropertiesConfigurationのファイルへの参照
- 情報1 = "ジョーイ"
- 情報2 = "ディーディー"
- 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>