123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?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:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
- 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/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
- http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
- <!--扫描需要扫描的包-->
- <context:component-scan base-package="com.sf"></context:component-scan>
- <!--导入外部属性资源文件 db.properties-->
- <context:property-placeholder location="classpath:db.properties"></context:property-placeholder>
- <!--配置数据库连接池-->
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
- <property name="url" value="${jdbc_url}" />
- <property name="username" value="${jdbc_user}" />
- <property name="password" value="${jdbc_password}" />
- <property name="filters" value="stat" />
- <property name="maxActive" value="20" />
- <property name="initialSize" value="1" />
- <property name="maxWait" value="60000" />
- <property name="minIdle" value="1" />
- <property name="timeBetweenEvictionRunsMillis" value="60000" />
- <property name="minEvictableIdleTimeMillis" value="300000" />
- <property name="testWhileIdle" value="true" />
- <property name="testOnBorrow" value="false" />
- <property name="testOnReturn" value="false" />
- <property name="poolPreparedStatements" value="true" />
- <property name="maxOpenPreparedStatements" value="20" />
- <property name="asyncInit" value="true" />
- </bean>
- <!--sqlSessionFactory-->
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource"/>
- <!--mybatis核心配置-->
- <property name="configLocation" value="classpath:mybatis-config.xml"></property>
- <!--SQL MAP -->
- <property name="mapperLocations" value="classpath:mapper/*.xml"></property>
- <!--别名-->
- <property name="typeAliasesPackage" value="com.sf.entity"></property>
- </bean>
- <!--配置平台事务管理器-->
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource"/>
- </bean>
- <!--将mybatis 接口加入到IOC中-->
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
- <property name="basePackage" value="com.sf.mapper"></property>
- </bean>
- <!--开启基于注解的声明式事物-->
- <tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven>
- </beans>
|