spring-boot报错循环注入报错:has been injected into other beans

1,581 阅读1分钟

报错

 Error creating bean with name 'SadFormService': Bean with name 'SadFormService' has been injected into other beans [SadFormDetailService] 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.
Error creating bean with name 'sadFormController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'SadFormService': Bean with name 'SadFormService' has been injected into other beans [SadFormDetailService] 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.

是因为A service和B service 循环注入导致,在出现冲突的注入上面加一个注解即可

@Lazy

在这里插入图片描述