dispatcher-Servlet.xml 설정. 또는 applicationContext.xml
* <context:component-scan ...> 바로 뒤에 <ehcache:annotation-driven ..> 와야 한다고 한다.
<?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:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.2.xsd"> <context:annotation-config /> <context:component-scan base-package="com.samsung.mcm.master" /> <!-- Ehcache --> <ehcache:annotation-driven cache-manager="cacheManager" /> <ehcache:config cache-manager="cacheManager"> <ehcache:evict-expired-elements interval="60" /> </ehcache:config> <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation" value="classpath:ehcache.xml"></property> </bean> ...
ehcache.xml 설정
<?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"> <defaultCache eternal="false" maxElementsInMemory="100" overflowToDisk="false" /> <cache name="countCache" maxElementsInMemory="10" eternal="false" overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0" timeToLiveSeconds="60" memoryStoreEvictionPolicy="LRU" /> </ehcache>
annotation 설정
@Cacheable(cacheName = "countCache") public List<TestObject> getCount() { return testMapper.selectCount(); }
ref:
http://javacan.tistory.com/123
http://shonm.tistory.com/m/post/view/id/437
'framework&tools > spring' 카테고리의 다른 글
Spring Controller에 Validator 적용하기 (0) | 2013.03.08 |
---|---|
Tomcat6에서 Spring 3 의 MultipartFile 처리 (0) | 2012.07.11 |
spring mvc annotation으로만 구현해보기 (0) | 2012.04.04 |