java.lang.IllegalArgumentException: Cannot find cache named 'product:categoryEntity' for Builder[public com.zg101.zane.service.api.base.BaseResponse com.zg101.zane.product.service.impl.CategoryServiceImpl.listCategory(java.lang.String)] caches=[product:categoryEntity] | key='#enable' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false'
Hi bro,
You can add org.springframework.cache.CacheManager config with your SpringApplication
like this:
@Configuration
public class MyCacheConfig {
@Autowired
RedissonClient redissonClient;
@Bean
CacheManager cacheManager() {
return new RedissonSpringCacheManager(redissonClient);
}
}
than restart your application, test your @Caheable...
:redisson-spring-boot-starter:3.13.2
:spring-boot:2.3.0.RELEASE
sure, you can configuration more in RedissonSpringCacheManager's constructor
在配置文件中指定缓存类型:
spring:
cache:
type: redis
It work, but why?
We don't need to set anything without redisson dependency.
test with this
xml
<!-- https://mvnrepository.com/artifact/org.redisson/redisson-spring-boot-starter -->
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.14.1</version>
</dependency>
Most helpful comment
在配置文件中指定缓存类型:
spring:
cache:
type: redis