applicationcontext-database.xml 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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"
  4. xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  7. http://www.springframework.org/schema/aop
  8. http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
  9. http://www.springframework.org/schema/tx
  10. http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
  11. <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  12. <property name="fileEncoding" value="utf-8" />
  13. <property name="locations">
  14. <list>
  15. <value>classpath*:jdbc.properties</value>
  16. </list>
  17. </property>
  18. </bean>
  19. <!-- part 1 :for datasource -->
  20. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
  21. <property name="driverClass" value="${c3p0.driverClass}" />
  22. <property name="jdbcUrl" value="${c3p0.url}" />
  23. <property name="user" value="${c3p0.user}" />
  24. <property name="password" value="${c3p0.password}" />
  25. <property name="initialPoolSize" value="3" />
  26. <property name="minPoolSize" value="2" />
  27. <property name="maxPoolSize" value="10" />
  28. <property name="maxIdleTime" value="60" />
  29. <property name="acquireRetryDelay" value="1000" />
  30. <property name="acquireRetryAttempts" value="10" />
  31. <property name="preferredTestQuery" value="SELECT 1" />
  32. </bean>
  33. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  34. <property name="dataSource" ref="dataSource" />
  35. <property name="mapperLocations" value="classpath:mybatis-mapper/*.xml"/>
  36. </bean>
  37. <!-- scope must be "prototype" when junit -->
  38. <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">
  39. <constructor-arg index="0" ref="sqlSessionFactory" />
  40. </bean>
  41. <!-- part 2 :for tx -->
  42. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  43. <property name="dataSource" ref="dataSource" />
  44. </bean>
  45. <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
  46. <tx:advice id="txAdvice" transaction-manager="transactionManager">
  47. <tx:attributes>
  48. <tx:method name="detail*" propagation="SUPPORTS" />
  49. <tx:method name="visit*" propagation="SUPPORTS" />
  50. <tx:method name="get*" propagation="SUPPORTS" />
  51. <tx:method name="find*" propagation="SUPPORTS" />
  52. <tx:method name="check*" propagation="SUPPORTS" />
  53. <tx:method name="list*" propagation="SUPPORTS" />
  54. <tx:method name="*" propagation="REQUIRED" rollback-for="exception" />
  55. </tx:attributes>
  56. </tx:advice>
  57. <aop:config>
  58. <aop:pointcut id="txoperation" expression="execution(* com.xxl.job.admin.service.impl.*.*(..))" />
  59. <aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
  60. </aop:config>
  61. </beans>