spring-batch.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
  5. xmlns:tx="http://www.springframework.org/schema/tx" xmlns:cache="http://www.springframework.org/schema/cache"
  6. xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
  7. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  8. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  9. http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
  10. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
  11. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
  12. default-lazy-init="true">
  13. <!-- 脱离web环境执行批次的配置文件,此文件禁止修改! -->
  14. <!-- 加载配置属性文件 -->
  15. <context:property-placeholder location="classpath*:jdbc.properties" ignore-unresolvable="false"/>
  16. <!-- 动态引用spring对象工具 -->
  17. <bean id="ehcacheManager" class="org.springframework.cache.jcache.JCacheManagerFactoryBean">
  18. <property name="configLocation" value="classpath:ehcache-spring.xml" />
  19. </bean>
  20. <!-- 配置数据源 -->
  21. <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  22. <property name="driverClassName" value="${jdbc.driverClassName}"/>
  23. <property name="url" value="${jdbc.url}"/>
  24. <property name="username" value="${jdbc.username}"/>
  25. <property name="password" value="${jdbc.password}"/>
  26. </bean>
  27. <!-- MyBatis配置 -->
  28. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  29. <property name="dataSource" ref="dataSource" />
  30. <property name="configLocation" value="classpath:mybatis-config.xml" />
  31. <property name="mapperLocations">
  32. <list>
  33. <value>classpath*:/com/sundata/**/mybatis/*.xml</value>
  34. </list>
  35. </property>
  36. </bean>
  37. <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
  38. <constructor-arg index="0" ref="sqlSessionFactory" />
  39. </bean>
  40. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  41. <property name="basePackage" value="com.sundata.**.mapper" />
  42. <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
  43. </bean>
  44. <!-- 事务配置 -->
  45. <bean id="transactionManager"
  46. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  47. <property name="dataSource" ref="dataSource" />
  48. </bean>
  49. <!-- 批次默认不启动事务
  50. <tx:advice id="txAdvice" transaction-manager="transactionManager">
  51. <tx:attributes>
  52. <tx:method name="get*" read-only="true" />
  53. <tx:method name="query*" read-only="true" />
  54. <tx:method name="find*" read-only="true" />
  55. <tx:method name="load*" read-only="true" />
  56. <tx:method name="select*" read-only="true" />
  57. <tx:method name="*" propagation="REQUIRED" no-rollback-for="com.sundata.common.exception.NoRollbackException"/>
  58. </tx:attributes>
  59. </tx:advice>
  60. <aop:config>
  61. <aop:advisor pointcut="execution(* com.sundata..service.*.*(..)) or execution(* com.sundata..batchService.*.*(..))" advice-ref="txAdvice" />
  62. </aop:config> -->
  63. <!-- spring配置 -->
  64. <tx:annotation-driven proxy-target-class="true"/>
  65. <context:annotation-config />
  66. <aop:aspectj-autoproxy />
  67. <context:component-scan base-package="com.sundata" >
  68. <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
  69. </context:component-scan>
  70. <!--开启spring cache注解-->
  71. <cache:annotation-driven mode="proxy" cache-manager="cacheManager"/>
  72. <!--CacheManager-->
  73. <bean id="cacheManager" class="org.springframework.cache.jcache.JCacheCacheManager">
  74. <property name="cacheManager" ref="jCacheManagerFactory"/>
  75. </bean>
  76. <!--这里的JCacheManagerFactory就相当于CachingProvider,通过CachingProvider就可以得到CacheManager,-->
  77. <!--JCacheManagerFactoryBean是一个FactoryBean,通过getObject可以得到CacheManager实例-->
  78. <bean id="jCacheManagerFactory"
  79. class="org.springframework.cache.jcache.JCacheManagerFactoryBean">
  80. <!--这里只能配置一个ehcache文件-->
  81. <property name="cacheManagerUri" value="classpath:ehcache-batch.xml" />
  82. </bean>
  83. </beans>