码迷,mamicode.com
首页 > 编程语言 > 详细

spring中使用 @value 简化配置文件的读取

时间:2015-06-29 19:54:44      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:

1、在applicationContext.xml文件中配置properties文件

    <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>
                <value>classpath:sysconfig.properties</value>
            </list>
        </property>
    </bean>

2.在实现类中使用@value注解获取 配置文件的值。

@Value("${responseUrl.count}")
private int count;

 

spring中使用 @value 简化配置文件的读取

标签:

原文地址:http://www.cnblogs.com/binggu/p/4607719.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!