springboot3.2引入caffeine出现的版本问题
一开始我直接引入了以下pom依赖
<dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> <version>2.6.2</version> </dependency>
在启动类上添加了@EnableCaching注解
报错为
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheManager' defined in class path resource
[org/springframework/boot/autoconfigure/cache/CaffeineCacheConfiguration.class]: Failed to instantiate [org.springframework.cache.caffeine.CaffeineCacheManager]:
Factory method 'cacheManager' threw exception with message: com/github/benmanes/caffeine/cache/AsyncCache
这里是版本依赖问题,后续我将caffeine改为2.9.2版本就可以正常使用
<dependency> <groupId>com.github.ben-manes.caffeine</groupId> <artifactId>caffeine</artifactId> <version>2.9.2</version> </dependency>