spring-dao.xml 2.27 KB
<?xml version="1.0" encoding="GBK"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"
       default-autowire="byName">

	<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource"
		destroy-method="close">
		<property name="driverClass" value="${bonecp.driverClass}" />
		<property name="jdbcUrl" value="${bonecp.jdbcUrl}" />
		<property name="username" value="${bonecp.username}" />
		<property name="password" value="${bonecp.password}" />
		<property name="idleConnectionTestPeriodInMinutes" value="${bonecp.idleConnectionTestPeriodInMinutes}" />
		<property name="idleMaxAgeInMinutes" value="${bonecp.idleMaxAgeInMinutes}" />
		<property name="partitionCount" value="${bonecp.partitionCount}" />
		<property name="maxConnectionsPerPartition" value="${bonecp.maxConnectionsPerPartition}" />
		<property name="minConnectionsPerPartition" value="${bonecp.minConnectionsPerPartition}" />
		<property name="acquireIncrement" value="${bonecp.acquireIncrement}" />
		<property name="statementsCacheSize" value="${bonecp.statementsCacheSize}" />
		<property name="releaseHelperThreads" value="${bonecp.releaseHelperThreads}" />
		<property name="connectionTestStatement" value="select 1" />
	</bean>

	<bean id="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>

	<tx:annotation-driven transaction-manager="transactionManager" />

	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="configLocation" value="classpath:/mybatis/mybatis.cfg.xml" />
        <property name="mapperLocations">
            <list>
                <value>classpath:/mybatis/sqlmap/*Dao.xml</value>
            </list>
        </property>
		<property name="dataSource" ref="dataSource" />
	</bean>

	<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
		<constructor-arg index="0" ref="sqlSessionFactory" />
	</bean>
</beans>