123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
- xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx" xmlns:cache="http://www.springframework.org/schema/cache"
- xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
- http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
- default-lazy-init="true">
- <!-- 脱离web环境执行批次的配置文件,此文件禁止修改! -->
- <!-- 加载配置属性文件 -->
- <context:property-placeholder location="classpath*:jdbc.properties" ignore-unresolvable="false"/>
- <!-- 动态引用spring对象工具 -->
- <bean id="ehcacheManager" class="org.springframework.cache.jcache.JCacheManagerFactoryBean">
- <property name="configLocation" value="classpath:ehcache-spring.xml" />
- </bean>
- <!-- 配置数据源 -->
- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName" value="${jdbc.driverClassName}"/>
- <property name="url" value="${jdbc.url}"/>
- <property name="username" value="${jdbc.username}"/>
- <property name="password" value="${jdbc.password}"/>
- </bean>
- <!-- MyBatis配置 -->
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource" />
- <property name="configLocation" value="classpath:mybatis-config.xml" />
- <property name="mapperLocations">
- <list>
- <value>classpath*:/com/sundata/**/mybatis/*.xml</value>
- </list>
- </property>
- </bean>
- <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
- <constructor-arg index="0" ref="sqlSessionFactory" />
- </bean>
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="com.sundata.**.mapper" />
- <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
- </bean>
-
- <!-- 事务配置 -->
- <bean id="transactionManager"
- class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource" />
- </bean>
- <!-- 批次默认不启动事务
- <tx:advice id="txAdvice" transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name="get*" read-only="true" />
- <tx:method name="query*" read-only="true" />
- <tx:method name="find*" read-only="true" />
- <tx:method name="load*" read-only="true" />
- <tx:method name="select*" read-only="true" />
- <tx:method name="*" propagation="REQUIRED" no-rollback-for="com.sundata.common.exception.NoRollbackException"/>
- </tx:attributes>
- </tx:advice>
- <aop:config>
- <aop:advisor pointcut="execution(* com.sundata..service.*.*(..)) or execution(* com.sundata..batchService.*.*(..))" advice-ref="txAdvice" />
- </aop:config> -->
- <!-- spring配置 -->
- <tx:annotation-driven proxy-target-class="true"/>
- <context:annotation-config />
- <aop:aspectj-autoproxy />
- <context:component-scan base-package="com.sundata" >
- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
- </context:component-scan>
- <!--开启spring cache注解-->
- <cache:annotation-driven mode="proxy" cache-manager="cacheManager"/>
- <!--CacheManager-->
- <bean id="cacheManager" class="org.springframework.cache.jcache.JCacheCacheManager">
- <property name="cacheManager" ref="jCacheManagerFactory"/>
- </bean>
- <!--这里的JCacheManagerFactory就相当于CachingProvider,通过CachingProvider就可以得到CacheManager,-->
- <!--JCacheManagerFactoryBean是一个FactoryBean,通过getObject可以得到CacheManager实例-->
- <bean id="jCacheManagerFactory"
- class="org.springframework.cache.jcache.JCacheManagerFactoryBean">
- <!--这里只能配置一个ehcache文件-->
- <property name="cacheManagerUri" value="classpath:ehcache-batch.xml" />
- </bean>
- </beans>
|