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

相關文章
相關標籤/搜索