spring-cache.xml 2.09 KB
<?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:cache="http://www.springframework.org/schema/cache"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans.xsd
		 http://www.springframework.org/schema/cache 
		http://www.springframework.org/schema/cache/spring-cache-4.1.xsd">

	<cache:annotation-driven mode="proxy" cache-manager="cacheManager" proxy-target-class="false" order="1"/>
	<bean id="cacheManager" class="org.springframework.cache.support.CompositeCacheManager">
		<property name="cacheManagers">
		<list>
			<ref bean="local"/>
			<ref bean="center"/>
		</list>
		</property>
		<property name="fallbackToNoOpCache" value="true"/>
	</bean>
	
	<!--ehcache-->
	<bean id="local" class="org.springframework.cache.ehcache.EhCacheCacheManager">
        <property name="cacheManager" ref="ehcacheManager"/>
    </bean>
   
    <bean id="ehcacheManager" class="net.sf.ehcache.CacheManager">
    	<constructor-arg type="net.sf.ehcache.config.Configuration">
    		<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    			<property name="targetClass" value="org.springframework.cache.ehcache.EhCacheManagerUtils" />
    			<property name="targetMethod" value="parseConfiguration" />
    			<property name="arguments">
    				<list>  
		                <value>classpath:cache/ehcache.xml</value>  
		            </list>  
    			</property>
    		</bean>
    	</constructor-arg>
    </bean>
    
    <!-- delete
    <bean id="ehcacheManagerFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
        <property name="configLocation" value="classpath:cache/ehcache.xml"/>
    </bean>
     -->
    
	<bean id="center" class="org.springframework.data.redis.cache.RedisCacheManager">
		<constructor-arg>
		<ref bean="redisTemplate"/>
		</constructor-arg>
		<property name="cacheNames">
			<set>
			<value>API_SIT</value>
			<value>API_GZH</value>
			<value>CST</value>
			</set>
		</property>
	</bean>
</beans>