spring 属性文件加载

#jdbc.driverClassName=com.mysql.jdbc.Driver

#jdbc.url=jdbc:mysql://localhost/jbpmtest

#jdbc.username=root

#jdbc.password=root

jdbc.driverClassName=oracle.jdbc.driver.OracleDriver

jdbc.url=dbc:oracle:thin:@localhost:1521:ORCL

jdbc.username=framework

jdbc.password=framework

      

  <!-- 属性文件读入 -->

        <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
                <property name="locations">
                        <list>
                                <value>classpath*:conf/jdbc.properties</value>
                                <value>classpath*:conf/mail.properties</value>
                                <value>classpath:properties/*.properties</value>
                        </list>
                </property>
        </bean>

   <!-- 属性文件的使用-->

        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
                <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="minPoolSize" value="${jdbc.minPoolSize}"/>
                <property name="maxPoolSize" value="${jdbc.maxPoolSize}"/>
                <property name="maxIdleTime" value="${jdbc.maxIdleTime}"/>
                <property name="acquireIncrement" value="${jdbc.acquireIncrement}"/>
                <property name="maxStatements" value="${jdbc.maxStatements}"/>
                <property name="idleConnectionTestPeriod" value="${jdbc.idleConnectionTestPeriod}"/>
                <property name="acquireRetryAttempts" value="${jdbc.acquireRetryAttempts}"/>
                <property name="breakAfterAcquireFailure" value="${jdbc.breakAfterAcquireFailure}"/>
                <property name="testConnectionOnCheckout" value="${jdbc.testConnectionOnCheckout}"/>
        </bean>

猜你喜欢

转载自username2.iteye.com/blog/1821763