コンテキストファイルでpropertyConfigurerBeanを定義する必要があります。
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:abc.properties</value>
<value>classpath:efg.properties</value>
</list>
</property>
</bean>
編集:
使用するには、コンテキストファイルでBeanjava.util.Properties
を定義する必要があります。PropertiesFactoryBean
<bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location">
<list>
<value>classpath:abc_en.properties</value>
<value>classpath:abc_fr.properties</value>
</list>
</property>
</bean>
java.util.Properties
次に、クラスで変数を定義し、プロパティBeanをそのクラスにロードする必要があります。
public class MyClass {
@Autowired
private java.util.Properties properties;
public void myMethod() {
String a = properties.getProperty("a");
String b = properties.getProperty("b");
String c = properties.getProperty("c");
}
}
プロパティBeanをクラスにロードする方法は他にもありますが、@Autowired
アノテーションを使用する場合は、<context:annotation-config />
要素をコンテキストファイルに配置する必要があります。