配置文件中propertyConfigurer类的使用

在spring中,可以通过propertityConfigurer类在配置文件中加入外部配置文件,同时也可以指定外部文件的编码方式

例如:

    <!--引入jdbc.properties配置文件并设置该配置文件的编码方式-->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location">
            <value>classpath:jdbc.properties</value>
        </property>
        <property name="fileEncoding">
            <value>UTF-8</value>
        </property>
    </bean>

当然也可以同时引入多个配置文件:

    <!--引入多个配置文件-->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>
                <value>classpath:ftl.properties</value>
                <value>/resourse/spring/*.properties</value>
            </list>
        </property>
    </bean>

注意下,这里的<property name="locations">

如果写成了location,是不支持list多引入标签的




猜你喜欢

转载自blog.csdn.net/jqc874789596/article/details/79093764