Rev 3474 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?xml version="1.0" encoding="UTF-8"?><!-- Copyright 2010 The myBatis Team Licensed under the Apache License, Version2.0 (the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributedunder the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY KIND, either express or implied. See the License forthe specific language governing permissions and limitations under the License. --><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:jdbc="http://www.springframework.org/schema/jdbc"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"><!-- JDBC connection properties --><property name="driverClassName" value="com.mysql.jdbc.Driver" /><property name="url" value="#{systemProperties['dbHost']}" /><property name="username" value="root" /><property name="password" value="shop2020" /><!-- Pool size related properties --><!-- The initial number of connections that are created when the pool isstarted. --><property name="initialSize" value="2" /><!-- The maximum number of active connections that can be allocated fromthis pool at the same time, or negative for no limit. --><property name="maxActive" value="16" /><!-- The maximum number of milliseconds that the pool will wait (when thereare no available connections) for a connection to be returned before throwingan exception, or -1 to wait indefinitely. --><property name="maxWait" value="10000" /><!-- The SQL query that will be used to validate connections from thispool before returning them to the caller. If specified, this query MUST bean SQL SELECT statement that returns at least one row. --><property name="validationQuery" value="SELECT 1" /><!-- The indication of whether objects will be validated before being borrowedfrom the pool. If the object fails to validate, it will be dropped from thepool, and we will attempt to borrow another. --><property name="testOnBorrow" value="false" /><!-- The indication of whether objects will be validated by the idle objectevictor (if any). If an object fails to validate, it will be dropped fromthe pool. --><property name="testWhileIdle" value="true" /><!-- The minimum amount of time an object may sit idle in the pool beforeit is eligable for eviction by the idle object evictor. Setting it to 2 hours. --><property name="minEvictableIdleTimeMillis" value="7200000" /><!-- The number of milliseconds to sleep between runs of the idle objectevictor thread. When non-positive, no idle object evictor thread will berun. Setting it to 15 minutes. --><property name="timeBetweenEvictionRunsMillis" value="900000"></property><!-- Properties to prevent DB resource leaks --><!-- Flag to remove abandoned connections if they exceed the removeAbandonedTimout.If set to true a connection is considered abandoned and eligible for removalif it has been idle longer than the removeAbandonedTimeout. Setting thisto true can recover db connections from poorly written applications whichfail to close a connection. --><property name="removeAbandoned" value="true" /><!-- Timeout in seconds before an abandoned connection can be removed. --><property name="removeAbandonedTimeout" value="300" /><!-- Flag to log stack traces for application code which abandoned a Statementor Connection. Logging of abandoned Statements and Connections adds overheadfor every Connection open or new Statement because a stack trace has to begenerated --><property name="logAbandoned" value="true" /></bean><!-- transaction manager, use JtaTransactionManager for global tx --><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource" /></bean><!-- enable component scanning (beware that this does not enable mapperscanning!) --><context:component-scan base-package="in.shop2020.payment.handler" /><!-- enable autowire --><context:annotation-config /><!-- enable transaction demarcation with annotations --><tx:annotation-driven /><!-- define the SqlSessionFactory, notice that configLocation is not neededwhen you use MapperFactoryBean --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="configLocation" value="classpath:mybatis-config.xml" /></bean><!-- scan for mappers and let them be autowired --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="in.shop2020.payment.persistence" /></bean></beans>