问题
I want to load a properties in my project with:
<beans>
...
<context:annotation-config />
<bean id="properties_es"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="classpath:/texts/report_es.properties" />
</bean>
<bean id="properties_en"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="classpath:/texts/report_en.properties" />
</bean>
</beans>
And then I try to get both .properties
public class PropertiesManager {
public static enum LanguageEnum{es, en}
@Autowired
private java.util.Properties properties_es;
@Autowired
private java.util.Properties properties_en;
public String getProperty(LanguageEnum language, String key) {
switch (language) {
case es:
return properties_es.getProperty(key);
case en:
return properties_en.getProperty(key);
default:
return properties_en.getProperty(key);
}
}
}
But properties_es and properties_en have system info like: {file.encoding.pkg=sun.io, com.sun.enterprise.appname=j2ee, com.sun.aas.useNewClassLoader=true, ...} and not the info defined in the files .properties
来源:https://stackoverflow.com/questions/11653373/spring-mvc-2-5-load-property-propertiesfactorybean-doesnt-return-properties-in