87 lines
4.4 KiB
XML
87 lines
4.4 KiB
XML
<?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:mvc="http://www.springframework.org/schema/mvc"
|
|
xmlns:context="http://www.springframework.org/schema/context"
|
|
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
|
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
|
|
http://www.springframework.org/schema/mvc
|
|
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
|
|
http://www.springframework.org/schema/context
|
|
http://www.springframework.org/schema/context/spring-context-4.0.xsd
|
|
http://www.springframework.org/schema/aop
|
|
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
|
|
http://www.springframework.org/schema/tx
|
|
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd ">
|
|
|
|
<description>MyBatis Data Source Configuration</description>
|
|
|
|
<!-- SPRING TRANSACTION CONFIG -->
|
|
<tx:annotation-driven transaction-manager="transactionManager"/>
|
|
|
|
<!-- JDBC SOURCE CONFIG -->
|
|
<bean id="dataSource1" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
|
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
|
|
<property name="url" value="jdbc:mysql://localhost:3306/heating?characterEncoding=UTF-8"/>
|
|
<property name="username" value="root"/>
|
|
<property name="password" value="root"/>
|
|
<property name="minIdle" value="1"/>
|
|
<property name="maxIdle" value="5"/>
|
|
<property name="maxWait" value="3000"/>
|
|
<property name="maxActive" value="2"/>
|
|
<property name="initialSize" value="3"/>
|
|
<property name="testWhileIdle" value="true"/>
|
|
<property name="testOnBorrow" value="false"/>
|
|
<property name="testOnReturn" value="false"/>
|
|
<property name="validationQuery" value="SELECT 1"/>
|
|
<property name="timeBetweenEvictionRunsMillis" value="60000"/>
|
|
<property name="numTestsPerEvictionRun" value="2"/>
|
|
</bean>
|
|
|
|
<!-- <bean id="dataSource2" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
|
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
|
|
<property name="url" value="jdbc:jtds:sqlserver://localhost:1433/digmun"/>
|
|
<property name="username" value="sa"/>
|
|
<property name="password" value="sa"/>
|
|
<property name="minIdle" value="1"/>
|
|
<property name="maxIdle" value="5"/>
|
|
<property name="maxWait" value="3000"/>
|
|
<property name="maxActive" value="2"/>
|
|
<property name="initialSize" value="3"/>
|
|
<property name="testWhileIdle" value="true"/>
|
|
<property name="testOnBorrow" value="false"/>
|
|
<property name="testOnReturn" value="false"/>
|
|
<property name="validationQuery" value="SELECT 1"/>
|
|
<property name="timeBetweenEvictionRunsMillis" value="60000"/>
|
|
<property name="numTestsPerEvictionRun" value="2"/>
|
|
</bean> -->
|
|
|
|
<bean id="multipleDataSource" class="com.blxc.util.MultipleDataSource">
|
|
<property name="defaultTargetDataSource" ref="dataSource1"/>
|
|
<property name="targetDataSources">
|
|
<map>
|
|
<entry key="dataSource1" value-ref="dataSource1"/>
|
|
<!-- <entry key="dataSource2" value-ref="dataSource2"/> -->
|
|
</map>
|
|
</property>
|
|
</bean>
|
|
|
|
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
|
<property name="dataSource" ref="multipleDataSource"/>
|
|
<property name="mapperLocations" value="classpath:/com/blxc/mapper/**/*.xml"/>
|
|
</bean>
|
|
|
|
<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
|
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
|
|
<property name="basePackage" value="com.blxc"/>
|
|
<property name="annotationClass" value="com.blxc.common.annotation.MyBatis"/>
|
|
</bean>
|
|
|
|
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
|
|
<constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"/>
|
|
</bean>
|
|
|
|
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
|
<property name="dataSource" ref="multipleDataSource"/>
|
|
</bean>
|
|
</beans> |