applicationcontext-database.xml 3.3 KB

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