利用@value获取配置文件的信息

来源:互联网 发布:linux curl命令详解 编辑:程序博客网 时间:2024/05/16 11:11

1.配置
在applicationContext.xml 中配置

    <bean id="themisFrontCommon" class="org.springframework.beans.factory.config.PropertiesFactoryBean">          <!-- 解决中文乱码问题 -->        <property name="fileEncoding" value="utf-8"/>        <property name="locations">              <list>                  <value>classpath:/config/test.properties</value>                <value>classpath:/config/ThemisFrontCommon.properties</value>              </list>          </property>      </bean> 

2.使用

    @Value("#{themisFrontCommon['test.name']}")     private String WebFileHtml;    @Value("#{themisFrontCommon['signName']}")     private String signName;    @Value("#{themisFrontCommon['test']}")     private String test;