123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?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:aop="http://www.springframework.org/schema/aop"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:jdbc="http://www.springframework.org/schema/jdbc"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
- default-lazy-init="true" >
- <context:component-scan base-package="cn.ourwill" >
- <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
- <context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
- </context:component-scan>
-
- <!-- 配置文件加载 -->
- <bean id="propertyConfigurer"
- class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="locations">
- <list>
- <value>classpath:/project.properties</value>
- </list>
- </property>
- </bean>
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="url" value="${jdbc.url}"/>
- <property name="username" value="${jdbc.username}"/>
- <property name="password" value="${jdbc.password}"/>
- <!-- 配置初始化大小、最小、最大 -->
- <property name="initialSize" value="${jdbc.initialPoolSize}" />
- <property name="minIdle" value="${jdbc.minPoolSize}" />
- <property name="maxActive" value="${jdbc.maxPoolSize}" />
- <!-- 配置获取连接等待超时的时间 -->
- <property name="maxWait" value="60000" />
- <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
- <property name="timeBetweenEvictionRunsMillis" value="60000" />
- <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
- <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" />
- <!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
- <!-- <property name="poolPreparedStatements" value="false" /> -->
- <!-- <property name="maxPoolPreparedStatementPerConnectionSize" value="20" /> -->
- <!-- 配置监控统计拦截的filters -->
- <property name="filters" value="stat" />
- </bean>
-
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource"></property>
- </bean>
- <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
-
- <!-- 扫描basePackage下所有以@MyBatisDao注解的接口 -->
- <bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
- <property name="basePackage" value="cn.ourwill"/>
- <property name="annotationClass" value="cn.ourwill.core.dao.MyBatisDao"/>
- </bean>
-
-
- <!-- 本项目数据源代码-->
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource" />
- <!-- 显式指定Mapper文件位置 -->
- <property name="configLocation" value="classpath:/mybatis-config.xml"/>
- <!-- 通配符指定Mapper.xml -->
- <property name="mapperLocations" value="classpath:/mappings/modules/**/*Dao.xml" />
- <!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 -->
- <property name="typeAliasesPackage" value="cn.ourwill" />
- <property name="typeAliasesSuperType" value="cn.ourwill.core.entity.BaseEntity"/>
- </bean>
-
- <bean id="sqlSessionMain" class="org.mybatis.spring.SqlSessionTemplate">
- <constructor-arg index="0" ref="sqlSessionFactory"/>
- </bean>
- <bean id="mybatisDao" class="cn.ourwill.module.house.dao.daily.MybatisDao">
- <property name="sqlSession" ref="sqlSessionFactory" />
- </bean>
-
- </beans>
|