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

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;

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