@Configuration
public class Test1 {
@Autowired
private Test3 test3;
}
@Configuration
public class Test2 {
@Autowired
private Test3 test3;
@Bean(name = "test3 ")
Test3 test3 () {
return new Test3();
}
}
The above code gives the following error.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'test1': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private Test3 com.package.name.Test1.test3;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'test2': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private Test3 com.package.name.Test2.test3;
nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'test3': Requested bean is currently in creation: Is there an unresolvable circular reference?
How is this an example of circular dependency? If it is, any ideas on resolving this.