<?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:context="http://www.springframework.org/schema/context"
|
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
|
http://www.springframework.org/schema/context
|
http://www.springframework.org/schema/context/spring-context.xsd">
|
|
<!--配数据源 -->
|
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
|
init-method="init" destroy-method="close">
|
<!--mysql 5连接驱动-->
|
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
|
<property name="url" value="jdbc:mysql://124.221.143.185:23306/smartlb?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false" />
|
|
<!-- <property name="url" value="jdbc:mysql://124.221.143.185:23306/smartlb?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false" />-->
|
<property name="username" value="smartlb" />
|
<property name="password" value="kabAG6TmMhrmB7MJ" />
|
<!--mysql 8连接驱动-->
|
<!-- <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>-->
|
<!-- <property name="url" value="jdbc:mysql://127.0.0.1:3306/smartlb?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false" />-->
|
<!-- <property name="username" value="root" />-->
|
<!-- <property name="password" value="password" />-->
|
|
<!-- 初始化连接大小 -->
|
<property name="initialSize" value="1" />
|
<!-- 连接池最大使用连接数量 -->
|
<property name="maxActive" value="20" />
|
|
<!-- 连接池最小空闲 -->
|
<property name="minIdle" value="1" />
|
<!-- 获取连接最大等待时间 -->
|
<property name="maxWait" value="60000" />
|
<property name="poolPreparedStatements" value="true" />
|
<property name="maxPoolPreparedStatementPerConnectionSize" value="33" />
|
<!-- 用来检测有效sql -->
|
<property name="validationQuery" value="${validationQuery}" />
|
<property name="testOnBorrow" value="false" />
|
<property name="testOnReturn" value="false" />
|
<property name="testWhileIdle" value="true" />
|
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
|
<property name="timeBetweenEvictionRunsMillis" value="60000" />
|
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
|
<property name="minEvictableIdleTimeMillis" value="25200000" />
|
<!-- 打开removeAbandoned功能 -->
|
<property name="removeAbandoned" value="true" />
|
<!-- 1800秒,也就是30分钟 -->
|
<property name="removeAbandonedTimeout" value="1800" />
|
<!-- 关闭abanded连接时输出错误日志 -->
|
<property name="logAbandoned" value="true" />
|
<!-- 监控数据库 -->
|
<property name="filters" value="mergeStat" />
|
</bean>
|
|
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
<property name="dataSource" ref="dataSource"></property>
|
</bean>
|
|
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
<property name="dataSource" ref="dataSource" />
|
<property name="configLocation" value="WEB-INF/config-mybatis.xml" />
|
</bean>
|
|
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
|
<constructor-arg index="0" ref="sqlSessionFactory" />
|
</bean>
|
|
<tx:annotation-driven transaction-manager="transactionManager"/>
|
|
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
|
<property name="basePackage" value="com.nanometer.smartlab.dao" />
|
</bean>
|
</beans>
|