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

一、在applicationContext.xml文件中配置properties文件spring

    <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注解获取 配置文件的值。app

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

相关文章
相关标签/搜索