SpringBoot - 不加 @EnableCaching 标签也一样可以在 Redis 中存储缓存?

网上文章都是说需要在 Application 上加 @EnableCaching 注解才能让缓存使用 Redis,但是测试发现不用 @EnableCaching 也可以使用 Redis,是网上文章有问题吗?

现在 Application 上用了 @EnableAsync,@SpringBootApplication,@EnableTransactionManagement,@MapperScan 这几个标签。

结论

  • 是自动装配了。很多注解不需要你手动申明的,满足条件就会自动装配
  • @EnableTransactionManagement 其实也是不需要写的,有 dataSource bean,就能自动生效
  • 可以用 Redis 和 @EnableCaching 是两个概念:SpringBoot 只要发现你有 Redis 的依赖就会做自动装配,但 @EnableCaching 是指自动装配的 CacheManager 这个 Bean 会否使用 Reids 实现其 API
相关推荐
JavaGuru_LiuYu1 小时前
Spring Boot 整合 SSE(Server-Sent Events)
java·spring boot·后端·sse
彭于晏Yan1 小时前
Springboot实现数据脱敏
java·spring boot·后端
super_lzb1 小时前
springboot打war包时将外部配置文件打入到war包内
java·spring boot·后端·maven
钱多多_qdd2 小时前
springboot注解(二)
java·spring boot·后端
钱多多_qdd3 小时前
springboot注解(五)
java·spring boot·后端
Psycho_MrZhang3 小时前
页缓存技术(PageCache/sendfile/mmap)
缓存
不如打代码KK4 小时前
Springboot如何解决跨域问题?
java·spring boot·后端
Java 码农4 小时前
gitlab gitrunner springboot 多环境多分支部署 (非容器方式,使用原生linux 环境)
linux·spring boot·gitlab
xiaolyuh1234 小时前
ThreadLocalMap 中弱引用被 GC 后的行为机制解析
java·jvm·redis
步步为营DotNet4 小时前
深度解析.NET中MemoryCache:高效缓存策略与性能优化的关键
缓存·性能优化·.net