spring读取properties文件配置使用

spring框架通过配置读取properties属性文件信息

在spring-applicationContext.xml文件中配置

<bean id="propertyConfigurerForEnv"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>file:/data/cnc/conf/*.properties</value>
            </list>
        </property>
    </bean>

这里的locations属性是一个集合,所以配置的时候可以配置多个,在java文件中可以使用@Value注解来获取属性文件中的数据

@Value("${t1.msgname}")

 

posted @ 2017-02-24 17:48  奔跑滴蜗牛  阅读(244)  评论(0编辑  收藏  举报