applicationContext-resources.xml 3.0 KB
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <!-- For mail settings and future properties files -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>
                <value>classpath:mail.properties</value>
                <value>classpath:hibernate.properties</value>
            </list>
        </property>
        <property name="systemPropertiesMode">
            <util:constant static-field="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
        </property>
    </bean>

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost/myproject?createDatabaseIfNotExist=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true"/>
        <property name="username" value="root"/>
        <property name="password" value="123456"/>
        <property name="maxActive" value="100"/>
        <property name="maxWait" value="1000"/>
        <property name="poolPreparedStatements" value="true"/>
        <property name="defaultAutoCommit" value="true"/>
        <property name="validationQuery" value="SELECT 1 + 1"/>
        <property name="testOnBorrow" value="true"/>
    </bean>

    <bean id="posgreDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="org.postgresql.Driver"/>
        <!--property name="url" value="jdbc:sqlserver://10.54.152.13:1433;DatabaseName=SMTMat"/-->
        <property name="url" value="jdbc:postgresql://192.168.10.2:5432/postgres"/>
        <property name="username" value="postgres"/>
        <property name="password" value="postgres"/>
        <property name="maxActive" value="20"/>
        <property name="maxWait" value="1000"/>
        <property name="poolPreparedStatements" value="true"/>
        <property name="defaultAutoCommit" value="true"/>
        <property name="validationQuery" value="SELECT 1 + 1"/>
        <property name="testOnBorrow" value="true"/>
    </bean>


    <!-- 下面定义了DbUtils的一个模板操作Bean -->
    <bean id="dbUtilsTemplate" class="com.myproject.dao.DbUtilsTemplate">
        <property name="posgreDataSource" ref="posgreDataSource" />
    </bean>

    <!--
    <import resource="mongo.xml"/>
    -->
</beans>