注意:该方法,不兼容spring-boot 2.0
源码
https://github.com/foreveryang321/java-best-practice
自定义CacheExpire注解
1 | ({ElementType.METHOD, ElementType.TYPE}) |
自定义redis缓存管理器
1 | import lombok.extern.slf4j.Slf4j; |
RedisCacheWrapper.java
1 | import lombok.extern.slf4j.Slf4j; |
CacheUtils工具类
1 | import org.springframework.cache.annotation.CacheConfig; |
Redis相关Bean初始化
1 | import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer; |
pom.xml
1 | <dependency> |
使用例子
1 |
|