<?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-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<!--先导入属性文件-->
<context:property-placeholder location="classpath:config/jdbc.properties"/>
<!-- 配制数据库,数据源配制 -->
<bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource">
<!-- 连接参数 -->
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<!-- 初始化配制 -->
<property name="initialSize" value="5"/>
<property name="minIdle" value="2"/>
<property name="maxActive" value="20"/>
<!-- 配制获取连接等待超过的时间 -->
<property name="maxWait" value="200000"/>
<!-- 配制一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000"/>
<property name="validationQuery" value="SELECT 'x'" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<!-- 是否缓存预编译语句 -->
<property name="poolPreparedStatements" value="true"/>
<property name="maxPoolPreparedStatementPerConnectionSize" value="20"/>
</bean>
<!-- 配制会话工厂 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- MyBatis主配制文件位置 -->
<property name="configLocation" value= "classpath:mybatis/MyBatisConfig.xml"></property>
<!-- 配制数据源 -->
<property name="dataSource" ref="druidDataSource"/>
<!-- 指定别名 对象的包名,创建这个com.trans.pojo包所有的类名相同的别名 -->
<property name="typeAliasesPackage" value="com.szsxt.yt.pojo"/>
</bean>
<!-- 扫描Mapper文件和Mapper接口 -->
<bean class= "org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 设置扫描的包 -->
<property name="basePackage" value="com.szsxt.yt.mapper"/>
<!-- 配制会话工厂的名称 -->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
</beans>