作者,你好
我在项目中使用Maven集成了jetcache-starter-redis-springdata, version=2.6.0 启动后一直报循环依赖
Error creating bean with name 'globalCacheConfig' defined in class path resource [com/alicp/jetcache/autoconfigure/JetCacheAutoConfiguration.class]: Circular depends-on relationship between 'globalCacheConfig' and 'springDataRedisAutoInit'
我想使用@CreateCache注解创建一个远程Cache
代码类型于:
@CreateCache(name = "XXX", cacheType = CacheType.REMOTE)
private Cache<String, XXXModel> xxxCache;
POM依赖
<!-- jetcache 缓存支持 -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-starter-redis-springdata</artifactId>
</dependency>
<!-- 添加对连接池的支持 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
我的项目环境信息:
springboot: 2.1.9
springcloud: Greenwich.SR4
配置文件:
jetcache:
statIntervalMinutes: 15
areaInCacheName: false
hidePackages: com.xxxx
local:
默认2小时本地缓存
default:
type: caffeine
keyConvertor: fastjson
expireAfterWriteInMillis: xxxx
expireAfterAccessInMillis: xxxx
longTime:
type: caffeine
keyConvertor: fastjson
expireAfterWriteInMillis: xxxx
expireAfterAccessInMillis: xxxx
shortTime:
type: caffeine
keyConvertor: fastjson
expireAfterWriteInMillis: xxxx
expireAfterAccessInMillis: xxxx
remote:
default:
type: redis.springdata
expireAfterWriteInMillis: xxxx
keyConvertor: fastjson
valueEncoder: kryo
valueDecoder: kryo
poolConfig:
minIdle: 5
maxIdle: 20
maxTotal: 50
longTime:
type: redis.springdata
expireAfterWriteInMillis: xxxx
keyConvertor: fastjson
valueEncoder: kryo
valueDecoder: kryo
poolConfig:
minIdle: 5
maxIdle: 20
maxTotal: 50
shortTime:
type: redis.springdata
expireAfterWriteInMillis: xxxx
keyConvertor: fastjson
valueEncoder: kryo
valueDecoder: kryo
poolConfig:
minIdle: 5
maxIdle: 20
maxTotal: 50
如果我单独引用 jetcache-starter-redis 是可以启动成功,但是这样我需要在jetcache下再单独配置一份redis,希望作者能帮忙解答下,谢谢
8条答案
按热度按时间x33g5p2x1#
经过确认,我引入2.5.16版本可以,但是2.6.0会一直报这个问题
com.alicp.jetcache
jetcache-starter-redis-lettuce
2.5.16
iezvtpos2#
我也有一样的问题。 在jetcache 里配置type: redis.springdata. 使用springdata的redis 是
使用的时候
` @CreateCache(area = "systemcenter", name = "version", expire = 3600, cacheType = CacheType.REMOTE)
@cacherefresh(refresh = 10)
@CachePenetrationProtect
private Cache<String, List> versionCache;
如果使用了PostConstruct ,就会导致出现问题,如果不使用,就不会出现
错误是:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aservice': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'globalCacheConfig' defined in class path resource [com/alicp/jetcache/autoconfigure/JetCacheAutoConfiguration.class]: Circular depends-on relationship between 'globalCacheConfig' and 'springDataRedisAutoInit'
0h4hbjxa3#
遇到了同样的问题
j13ufse24#
Error creating bean with name 'globalCacheConfig' defined in class path resource [com/alicp/jetcache/autoconfigure/JetCacheAutoConfiguration.class]: Circular depends-on relationship between 'globalCacheConfig' and 'springDataRedisAutoInit'
碰到了同样的问题
esbemjvw5#
同样的问题
x33g5p2x6#
使用 CommandLineRunner 吧。
ig9co6j17#
遇到了同样的问题
vs3odd8k8#
可以 实现ApplicationRunner接口,重写run方法,可以实现@PostConstruct注解的效果