直接上代码:
<cache:annotation-driven /> <bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager"> <property name="caches"> <set> <!-- 可以配置多个 --> <bean name="accessCode" class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean"/> </set> </property> </bean>
方法:
@Cacheable(value="accessCode",key="#userId + #menuUrl") public PageAccessCode getPageAccessCode(Integer userId, String menuUrl,String curLang){ }