当前位置 博文首页 > Jqcode:配置文件中propertyConfigurer类的使用

    Jqcode:配置文件中propertyConfigurer类的使用

    作者:[db:作者] 时间:2021-09-16 10:39

    在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多引入标签的




    cs