PropertyPlaceholderConfigurer加載屬性配置文件:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4        xmlns:p="http://www.springframework.org/schema/p"
 5        xsi:schemaLocation="
 6         http://www.springframework.org/schema/beans 
 7         http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
 8 <!-- 使用spring提供的PropertyPlaceholderConfigurer讀取數據庫配置信息.properties -->
 9     <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
10         <property name="locations">
11             <list>
12                 <!--
13                     這裏的classpath能夠認爲是項目中的src-屬性名是 locations,
14                     使用子標籤<list></list>能夠指定多個數據庫的配置文件,這裏指定了一個
15                 -->
16                 <value>classpath:resource/config/jdbc.properties</value>
17             </list>
18         </property>
19     </bean>
20 </beans>
相關文章
相關標籤/搜索