Recently, the project used tomcat jdbc pool and mybatis, the database connection pool that comes with Spring and tomcat 7, and now records the configuration of the Three Integration for emergency purposes.
Jar package:
Jar packages required by the spring framework (I will not elaborate on them here)
Mybatis-3.1.1.jar
Mybatis-spring-1.1.1.jar
Mysql-connector-java-5.1.15-bin.jar
Tomcat-jdbc.jar
Tomcat-juli.jar
The configuration file is as follows:
[Html]
<? 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: p = "http://www.springframework.org/schema/p"
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-3.0.xsd
Http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd ">
<! -- Tomcat jdbc pool data source configuration -->
<Bean id = "dataSource" class = "org. apache. tomcat. jdbc. pool. DataSource" destroy-method = "close">
<Property name = "poolProperties">
<Bean class = "org. apache. tomcat. jdbc. pool. PoolProperties">
<Property name = "driverClassName" value = "com. mysql. jdbc. Driver"/>
<Property name = "url" value = "jdbc: mysql: // localhost: 3306/test? AutoReconnect = true & useUnicode = true & characterEncoding = UTF-8 "/>
<Property name = "username" value = "root"/>
<Property name = "password" value = ""/>
<Property name = "jmxEnabled" value = "true"/>
<Property name = "testWhileIdle" value = "true"/>
<Property name = "testOnBorrow" value = "true"/>
<Property name = "testOnReturn" value = "false"/>
<Property name = "validationInterval" value = "30000" type = "codeph" text = "codeph"/>
<Property name = "validationQuery" value = "SELECT 1"/>
<Property name = "timeBetweenEvictionRunsMillis" value = "30000"/>
<Property name = "maxActive" value = "100"/>
<Property name = "initialSize" value = "10"/>
<Property name = "maxWait" value = "10000"/>
<Property name = "minEvictableIdleTimeMillis" value = "30000"/>
<Property name = "minIdle" value = "10"/>
<Property name = "logAbandoned" value = "false"/>
<Property name = "removeAbandoned" value = "true"/>
<Property name = "removeAbandonedTimeout" value = "60"/>
<Property name = "jdbcInterceptors" value = "org. apache. tomcat. jdbc. pool. interceptor. ConnectionState; org. apache. tomcat. jdbc. pool. interceptor. StatementFinalizer"/>
</Bean>
</Property>
</Bean>
<! -- Configure the Transaction Manager. Note that the dataSource here must be consistent with the dataSource of SqlSessionFactoryBean, otherwise the transaction will not work. -->
<Bean id = "transactionManager"
Class = "org. springframework. jdbc. datasource. DataSourceTransactionManager">
<Property name = "dataSource" ref = "dataSource"/>
</Bean>
<! -- Define the Interceptor to specify the transaction attributes, levels, and exception handling -->
<Bean id = "transactionInterceptor" class = "org. springframework. transaction. interceptor. TransactionInterceptor">
<Property name = "transactionManager" ref = "transactionManager"> </property>
<Property name = "transactionAttributes">
<Props>
<Prop key = "save *"> PROPAGATION_REQUIRED,-Exception </prop>
<Prop key = "update *"> PROPAGATION_REQUIRED,-Exception </prop>
<Prop key = "delete *"> PROPAGATION_REQUIRED,-Exception </prop>
<Prop key = "find *"> PROPAGATION_REQUIRED, readOnly </prop>
<Prop key = "get *"> PROPAGATION_REQUIRED, readOnly </prop>
</Props>
</Property>
</Bean>
<! -- Used to define which classes need Transaction Management spring transaction dynamic proxy class BeanNameAutoProxyCreator automatic proxy according to class name, accept expression -->
<Bean id = "BeanProxy" class = "org. springframework. aop. framework. autoproxy. BeanNameAutoProxyCreator">
<Property name = "beanNames">
<! -- Proxy for classes whose names end with Service -->
<Value> * Service </value>
</Property>
<! -- Load the Interceptor to the proxy class (the notification process) -->
<Property name = "interceptorNames">
<List>
<Value> transactionInterceptor </value>
</List>
</Property>
</Bean>
<Bean id = "sqlSessionFactory" class = "org. mybatis. spring. SqlSessionFactoryBean">
<Property name = "configLocation" value = "classpath: mybatis-config.xml"/>
<Property name = "dataSource" ref = "dataSource"/>
</Bean>
<Bean id = "authorityDao" class = "com. hongdian. ithings. authoritymanagement. dao. AuthorityDaoImpl">
<Property name = "sessionFactory" ref = "sqlSessionFactory"/>
</Bean>
<Bean id = "authorityService" class = "com. hongdian. ithings. authoritymanagement. service. AuthorityServiceImpl">
<Property name = "authorityDao" ref = "authorityDao"/>
</Bean>
<Bean class = "com. hongdian. ithings. authoritymanagement. common. SpringContext"> </bean>
<Bean id = "taskExecutor" class = "org. springframework. scheduling. concurrent. ThreadPoolTaskExecutor">
<! -- Number of active threads in the thread pool -->
<Property name = "corePoolSize" value = "5"/>
<! -- Maximum number of active threads in the thread pool -->
<Property name = "maxPoolSize" value = "50"/>
<! -- Maximum capacity of task queue -->
<Property name = "queueCapacity" value = "5"/>
</Bean>
<Bean id = "authorityComponent" class = "com. hongdian. ithings. authoritymanagement. communication. AuthorityComponent">
<Property name = "taskExecutor" ref = "taskExecutor"/>
</Bean>
</Beans>