| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?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:util="http://www.springframework.org/schema/util"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd">
-
- <context:property-placeholder location="classpath:jdbc.properties"/>
- <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
- <property name="driverClassName" value="${jdbc.driverClass}"></property>
- <property name="url" value="${jdbc.jdbcUrl}"></property>
- <property name="username" value="${jdbc.user}"></property>
- <property name="password" value="${jdbc.password}"></property>
- <property name="maxTotal" value="${jdbc.maxTotal}"></property>
- <property name="maxIdle" value="${jdbc.maxIdle}"></property>
- <property name="initialSize" value="${jdbc.initialSize}"></property>
- </bean>
- <!-- 配置事务管理器,依赖于数据源 -->
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <!-- 注入数据源 -->
- <property name="dataSource" ref="dataSource"/>
- </bean>
-
- <!-- 使用注解来控制事务 -->
- <tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven>
- <!-- 事务通知 -->
- <!-- <tx:advice id="txAdvice" transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name=""/>
- </tx:attributes>
- </tx:advice> -->
- <!-- 切面 -->
- <!-- <aop:config>
- <aop:advisor advice-ref="txAdvice" pointcut=""/>
- </aop:config> -->
-
- <!-- 配置mybatis会话工厂 -->
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="configLocation" value="classpath:mybatis-config.xml"></property>
- <!-- 注入数据源 -->
- <property name="dataSource" ref="dataSource"/>
- <!-- 指定mybatis映射文件位置 -->
- <property name="mapperLocations">
- <list>
- <value>classpath:mapper/*.xml</value>
- </list>
- </property>
- <!-- 配置pagehelper分页插件 -->
- <property name="plugins">
- <array>
- <bean class="com.github.pagehelper.PageInterceptor">
- <property name="properties">
- <value>
- pageSizeZero=true
- reasonable=true
- </value>
- </property>
- </bean>
- </array>
- </property>
-
- </bean>
- <!-- 配置mapper接口扫描器 -->
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="com.zhu.mapper"></property>
- </bean>
- <!-- 配置其他扫描器,如服务层-->
- <context:component-scan base-package="com.zhu.service"></context:component-scan>
- </beans>
|