zoukankan      html  css  js  c++  java
  • Spring PropertyPlaceholderConfigurer 站位

    1、 说明:

    Spring的框架中,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer类可以将.properties(key/value形式)文件中一些动态设定的值(value),在XML中替换为占位该键($key$)的值,.properties文件可以根据客户需求,自定义一些相关的参数,这样的设计可提供程序的灵活性。

    2、使用

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
       <property name="locations">
        <list>
         <value>/WEB-INF/mail.properties</value>    //处于WEB-INF目录下的文件
         <value>classpath: conf/sqlmap/jdbc.properties</value>//注意这两种value值的写法 ,处于src目录中的,也就是class中的。
        </list>
       </property>
    </bean>

    3、实例

     

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="locations">
    			<list>
    				<value>/WEB-INF/config/jdbc.properties</value>
    			</list>
    		</property>
    	</bean>
    	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    		<property name="driverClass" value="${jdbc.driverClassName}" />
    		<property name="jdbcUrl" value="${jdbc.url}" />
    		<property name="user" value="${jdbc.username}" />
    		<property name="password" value="${jdbc.password}" />
    		<property name="autoCommitOnClose" value="true"/>
    		<property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/>
    		<property name="initialPoolSize" value="${cpool.minPoolSize}"/>
    		<property name="minPoolSize" value="${cpool.minPoolSize}"/>
    		<property name="maxPoolSize" value="${cpool.maxPoolSize}"/>
    		<property name="maxIdleTime" value="${cpool.maxIdleTime}"/>
    		<property name="acquireIncrement" value="${cpool.acquireIncrement}"/>
    		<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}"/>
    	</bean>


  • 相关阅读:
    HDU 4607 Park Visit (DP最长链)
    HDU 4607 Park Visit (DP最长链)
    POJ 2388 Who's in the Middle (快速选择算法:O(N)求数列第K大)
    POJ 2388 Who's in the Middle (快速选择算法:O(N)求数列第K大)
    HDU 4609 3-idiots (FFT-快速傅立叶变换)
    HDU 4609 3-idiots (FFT-快速傅立叶变换)
    POJ 3084 Panic Room (最小割建模)
    POJ 3084 Panic Room (最小割建模)
    POJ 1966 Cable TV Network (无向图点连通度)
    POJ 1966 Cable TV Network (无向图点连通度)
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3106773.html
Copyright © 2011-2022 走看看