Description:
The dependencies of some of the beans in the application context form a cycle:
┌──->──┐
| redisConfiguration (field private redis.clients.jedis.JedisPoolConfig com.imooc.o2o.config.redis.RedisConfiguration.jedisPoolConfig)
└──<-──┘
Action:
Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘redisConfiguration’: Unsatisfied dependency expressed through field ‘jedisPoolConfig’; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name ‘redisConfiguration’: Requested bean is currently in creation: Is there an unresolvable circular reference?
报错原因说好像产生循环注入/依赖了?
我看视频直接用的最后项目给的配置,我用的也是最后项目的配置,应该没问题呀。properties也加了的。
是不是2.6版本Spring的检测特性?
我照着他的建议加一个设置允许循环注入试试。
在配置中加了个spring.main.allow-circular-references=true,可以了
是2.6版本Spring的特性,不允许循环注入/依赖,有相同问题的同学可以这样解决
SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需
了解课程