spring-mybatis.xml 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
  4. xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
  6. xmlns:util="http://www.springframework.org/schema/util"
  7. xmlns:repository="http://www.springframework.org/schema/data/repository"
  8. xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
  9. xsi:schemaLocation="
  10. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
  11. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  12. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
  13. http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
  14. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
  15. http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
  16. http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
  17. http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
  18. http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository.xsd
  19. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"
  20. default-lazy-init="true">
  21. <description>Spring Mybatis 配置 </description>
  22. <bean id="dataSource" class="com.xt.js.gkaq.web.system.DataSourceFactory"
  23. init-method="init" destroy-method="close">
  24. <property name="properties" value="classpath:/spring/dataSource.properties" />
  25. <property name="dsType" value="com.alibaba.druid.pool.DruidDataSource"></property>
  26. </bean>
  27. <!-- ================== mybatis ==================================== -->
  28. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  29. <property name="dataSource" ref="dataSource" />
  30. <property name="mapperLocations" value="classpath:com/xt/js/gkaq/*/mappers/*.xml" />
  31. <!-- 配置Mybatis的插件plugin -->
  32. <property name="plugins">
  33. <array>
  34. <bean class="com.yuanxd.tools.pagehelper.PageHelper">
  35. <property name="properties">
  36. <value>
  37. dialect=oracle
  38. </value>
  39. </property>
  40. </bean>
  41. </array>
  42. </property>
  43. </bean>
  44. <!-- 配置扫描器 -->
  45. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  46. <!-- 扫描me.gacl.dao这个包以及它的子包下的所有映射接口类 -->
  47. <property name="basePackage" value="com.xt.js.gkaq.*.mappers" />
  48. <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
  49. </bean>
  50. <!-- ========================================事务配置========================================= -->
  51. <!-- 配置Spring的事务管理器 -->
  52. <bean id="transactionManager"
  53. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  54. <property name="dataSource" ref="dataSource" />
  55. </bean>
  56. <aop:aspectj-autoproxy proxy-target-class="true" />
  57. <!-- 注解方式配置事物 -->
  58. <tx:annotation-driven transaction-manager="transactionManager" />
  59. </beans>