First download the correlation package in http://code.google.com/p/ehcache-spring-annotations/downloads/list. Import the project. Here is a more detailed introduction can be consulted.
In addition to the jar in the downloaded association package, Spring-context-support.jar, Cblib-2.2.jar is also required.
To configure spring:
<?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: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://ehcache-spring-annotations.googlecode.com/svn/ Schema/ehcache-spring http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ Ehcache-spring-1.1.xsd "> <ehcache:annotation-driven cache-manager=" Ehcachemanager "/> <bean id=" Ehcachemanager "class=" Org.springframework.cache.ehcache.EhCacheManagerFactoryBean "> <property name=" Configlocation "value="/web-inf/ehcache.xml "/> </bean> </beans>
Configuration Ehcache:
<?xml version= "1.0" encoding= "UTF-8"?> <ehcache xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: nonamespaceschemalocation= "Http://ehcache.org/ehcache.xsd" updatecheck= "false" > <diskstore path= " Java.io.tmpdir/ehcachespringannotationsexampleapp "/> <defaultcache eternal=" false "maxElementsInMemory=" "overflowtodisk=" false "Diskpersistent=" false "timetoidleseconds=" 0 "timetoliveseconds=" 600 " memorystoreevictionpolicy= "LRU"/> <cache name= "Metacolumncache" eternal= "false" maxelementsinmemory= "100" Overflowtodisk= "false" Diskpersistent= "false" timetoidleseconds= "0" timetoliveseconds= "300" memorystoreevictionpolicy= "LRU"/> </ehcache>
OK, how to use:
@Cacheable (cachename= "Metacolumncache")
Public List Getcolumnmodel (String tableId) {
//......
}