Spring MVC 2.5 load property PropertiesFactoryBean doesn't return .properties info

我只是一个虾纸丫 提交于 2020-01-16 18:39:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!