天天看点

spring PropertyPlaceholderConfigurer

<bean id="propertyConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<property name="locations">

    <list>

       <value>classpath:conf/database.properties</value>

    </list>

</property>

</bean>

项目启动时会加载spring的相关配置文件,该类会被实例化,也会将配置的properties文件加载到内存,比如数据库的连接信息,然后在datasource这个bean配置的时候可以使用形如${key}这样的形式,这里的key是配置在属性文件里的