错误信息:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘followController’: Unsatisfied dependency expressed through field ‘followService’; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name ‘followServiceImpl’: Bean with name ‘followServiceImpl’ has been injected into other beans [newIndexServiceImpl] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching – consider using ‘getBeanNamesOfType’ with the ‘allowEagerInit’ flag turned off, for example.
如遇到相似错误可以在service层注入时加Lazy(true)标签:
例如:
@Autowired @Lazy(true) private IFollowService followService;
则可以解决 循环引用 导致spring boot启动报错问题。
[注意: 尽量在涉及架构的时候 进行松耦合]
原文链接:https://blog.csdn.net/kingmax54212008/article/details/94396260