rtrh-mybatis.xml 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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:aop="http://www.springframework.org/schema/aop"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx"
  6. xmlns:jpa="http://www.springframework.org/schema/data/jpa"
  7. xsi:schemaLocation="
  8. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
  9. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
  10. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
  11. http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
  12. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
  13. http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.8.xsd">
  14. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  15. <property name="dataSource" ref="dataSource" />
  16. <property name="typeAliasesPackage" value="classpath*:/com.rtrh.core.plugins,com.rtrh.core.plugins,com.rtrh.demo.modules" />
  17. <!-- <property name="configLocation" value="classpath:mybatisMsSqlConfig.xml" /> -->
  18. <property name="mapperLocations" >
  19. <list>
  20. <value>classpath*:/com/rtrh/core/plugins/**/mapper/*Mapper.xml</value>
  21. <value>classpath*:/com/rtrh/projects/modules/**/*Mapper.xml</value>
  22. </list>
  23. </property>
  24. <property name="plugins">
  25. <list>
  26. <bean class="com.github.pagehelper.PageHelper">
  27. <property name="properties">
  28. <value>
  29. dialect=mysql
  30. reasonable=true
  31. </value>
  32. </property>
  33. </bean>
  34. </list>
  35. </property>
  36. </bean>
  37. <bean id="secondarySqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  38. <property name="dataSource" ref="dataSource" />
  39. <property name="typeAliasesPackage" value="classpath*:/com/rtrh/core/plugins,com.rtrh.core.plugins,com.rtrh.demo.modules" />
  40. <property name="mapperLocations">
  41. <list>
  42. <value>classpath*:/com/rtrh/core/plugins/**/mapper/*Mapper.xml</value>
  43. <value>classpath*:/com/rtrh/projects/modules/**/*Mapper.xml</value>
  44. </list>
  45. </property>
  46. <property name="plugins">
  47. <list>
  48. <bean class="com.github.pagehelper.PageHelper">
  49. <property name="properties">
  50. <value>
  51. dialect=mysql
  52. reasonable=true
  53. </value>
  54. </property>
  55. </bean>
  56. </list>
  57. </property>
  58. </bean>
  59. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  60. <property name="annotationClass" value="com.rtrh.core.repository.mybatis.MyBatisRepository" />
  61. <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
  62. <property name="basePackage" value="com.rtrh.core.plugins.**.mapper,com.rtrh.**.modules.**.mapper" />
  63. </bean>
  64. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  65. <property name="annotationClass" value="com.rtrh.core.repository.mybatis.MyBatisRepository" />
  66. <property name="sqlSessionFactoryBeanName" value="secondarySqlSessionFactory" />
  67. <property name="basePackage" value="com.rtrh.core.plugins.**.mapper,com.rtrh.**.modules.**.mapper" />
  68. </bean>
  69. <!-- 配置事务 -->
  70. <bean id="txManager_mybatis"
  71. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  72. <property name="dataSource" ref="poolDataSource" />
  73. </bean>
  74. <bean id="txManager_secondary"
  75. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  76. <property name="dataSource" ref="secondaryDataSource" />
  77. </bean>
  78. <!-- 配置基于注解的事物aop -->
  79. <tx:annotation-driven transaction-manager="txManager_mybatis" proxy-target-class="true"/>
  80. <tx:annotation-driven transaction-manager="txManager_secondary" proxy-target-class="true"/>
  81. </beans>