springboot 整合ehcache+redis 通过配置文件切换缓存类型
1、springboot 整合ehcache+redis 通过配置文件application.yml切换缓存类型 2、ehcache 、redis 通过缓存管理器管理 3、可分别设置缓存的过期时间 ehcache :添加依赖 pom.xml 2、添加配置文件ehcache.xml 3、添加注解@EnableCaching @Cacheable 4、插入缓存 5 读取缓存 6 设置缓存过期时间ehcache.xml -->timeToLiveSeconds。 redis : 1、添加依赖 pom.xml 2、主入口添加注解@EnableCaching 获取缓存方法添加@Cacheable 3、初始化缓存管理器 4 实现put get方法 其中一个put方法添加了过期时间 5 调用方法获取缓存 注意需要在本地部署redis服务注意密码问题