57 lines
2.3 KiB
XML
57 lines
2.3 KiB
XML
<?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"
|
|
xmlns:context="http://www.springframework.org/schema/context"
|
|
xmlns:p="http://www.springframework.org/schema/p"
|
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
|
http://www.springframework.org/schema/context
|
|
http://www.springframework.org/schema/context/spring-context.xsd
|
|
http://www.springframework.org/schema/cache
|
|
http://www.springframework.org/schema/cache/spring-cache.xsd">
|
|
|
|
<!-- Scans within the base package of the application for @Components to
|
|
configure as beans -->
|
|
<context:component-scan base-package="org.spring.cache.example" />
|
|
|
|
<!-- Process cache annotations -->
|
|
<cache:annotation-driven cache-manager="cacheManager"/>
|
|
|
|
<bean id="viewResolver"
|
|
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
|
<property name="viewClass">
|
|
<value>org.springframework.web.servlet.view.JstlView</value>
|
|
</property>
|
|
<property name="prefix" value="/WEB-INF/views/" />
|
|
<property name="suffix" value=".jsp" />
|
|
</bean>
|
|
|
|
|
|
|
|
<!-- Configuration for using Ehcache as the cache manager -->
|
|
<!-- 使用ehcache配置缓存 -->
|
|
|
|
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache" />
|
|
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:config-location="classpath:ehcache.xml" p:shared="true"/>
|
|
|
|
<!-- Configuration for using SimpleCacheManager as the cache manager -->
|
|
<!-- 使用Spring默认的缓存方案SimpleCacheManager,其内部使用了缺省的内存存储方案 ConcurrentMapCacheFactoryBean,它是基于 java.util.concurrent.ConcurrentHashMap 的一个内存缓存实现方案。 -->
|
|
<!--
|
|
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
|
|
<property name="caches">
|
|
<set>
|
|
<bean
|
|
class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
|
|
p:name="default" />
|
|
<bean
|
|
class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"
|
|
p:name="employeeCache" />
|
|
</set>
|
|
</property>
|
|
</bean>
|
|
-->
|
|
|
|
|
|
|
|
</beans> |