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
相关推荐
.格子衫.2 小时前
Spring Boot 原理篇
java·spring boot·后端
多云几多2 小时前
Yudao单体项目 springboot Admin安全验证开启
java·spring boot·spring·springbootadmin
摇滚侠3 小时前
Spring Boot 3零基础教程,Spring Intializer,笔记05
spring boot·笔记·spring
Jabes.yang4 小时前
Java求职面试实战:从Spring Boot到微服务架构的技术探讨
java·数据库·spring boot·微服务·面试·消息队列·互联网大厂
摇滚侠5 小时前
Spring Boot 3零基础教程,Demo小结,笔记04
java·spring boot·笔记
阿巴~阿巴~5 小时前
Redis 核心文件、命令与操作指南
数据库·redis·缓存·客户端·服务端
koping_wu5 小时前
【Redis】用Redis实现分布式锁、乐观锁
数据库·redis·分布式
huihuihuanhuan.xin7 小时前
后端八股之Redis
数据库·redis·缓存
Lucky GGBond8 小时前
Vue + Spring Boot 实现 Excel 导出实例
vue.js·spring boot·excel
seven97_top8 小时前
Springboot 常见面试题汇总
java·spring boot·后端