spring bean 读取外部properties文件

方法一:利用org.springframework.beans.factory.config.PropertyPlaceholderConfigurer

    <bean id="propertyConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:test.properties</value>
            </list>
        </property>
        <property name="fileEncoding" value="UTF-8"/>
    </bean>

方法二:利用context:property-placeholder

    <context:property-placeholder location="classpath:test.properties" file-encoding="utf-8"/>
posted @ 2018-10-10 16:03  Christopher丶  阅读(538)  评论(0编辑  收藏  举报