SpringMVC配置數據庫連接池


http://www.cnblogs.com/coqn/archive/2012/08/15/SpringMvc%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA%E9%85%8D%E7%BD%AE.html

SpringMvc環境搭建(配置文件)

 

spring配置:context:property-placeholder 讀取配置文件信息 在配置文件中使用el表達式填充值

spring將properties文件讀取后在配置文件中直接將對象的配置信息填充到bean中的變量里。

原本使用PropertyPlaceholderConfigurer類進行文件信息配置。 PropertyPlaceholderConfigurer實現了BeanFactoryPostProcessor接口,能夠 對<bean/>中的屬性值進行外在化管理。
<bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
    <list>
      <value>userinfo.properties</value>
    </list>
  </property>
</bean>
<bean name="userInfo" class="test.UserInfo">
  <property name="username" value="${db.username}"/>
  <property name="password" value="${db.password}"/>
</bean>

現在,直接使用
<context:property-placeholder location="classpath*:resources/*.properties" />

注意:spring容器中最多只能定義一個context:property-placeholder。

分類: spring
 
不知道這個對不對,先記錄下來


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM