`
rubyq
  • 浏览: 81872 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

Spring框架中的PropertyPlaceholderConfigurer类

阅读更多
Spring框架中的PropertyPlaceholderConfigurer类

PropertyPlaceholderConfigurer类可以在applicationContext.xml配置文件中加入一个或者多个外部属性文件properties(注意location和locations属性):

<!-- 一个外部文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
     <property name="location" value="classpath:/conf/jdbc-mysql.properties"/>
</bean>

<!-- 多个外部文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
     <property name="locations">
<list>
   <value>classpath*:/conf/jdbc-mysql.properties</value>     <value>classpath*:/conf/hibernate-mysql.properties</value>
</list>
      </property>
</bean>
<!--引用外部文件属性用${key}-->
<bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${c3p0.driverClassName}" />
<property name="jdbcUrl" value="${c3p0.jdbcUrl}" />
        <property name="user" value="${c3p0.user}" />
        <property name="password" value="${c3p0.password}" />
        <property name="maxPoolSize" value="${c3p0.maxPoolSize}" />
        <property name="minPoolSize" value="${c3p0.minPoolSize}" />
        <property name="initialPoolSize" value="${c3p0.initialPoolSize}" />
        <property name="breakAfterAcquireFailure" value="${c3p0.breakAfterAcquireFailure}" />
</bean>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics