使用spring注解标记的类不能互相引用否则会报spring创建类失败:
@Service //这里可以是spring四个注解中的任意一个
class A{
@Autowired
B b;
}
@Service
Class B{
@Autowired
A a;
}
此时会抛出异常
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '***': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: