私は、自動配線オーダーと@PostConstruct
ロジックについて、Springで質問しています。春のオートワイヤリングオーダーと@PostConstruct
@SpringBootApplication
public class Demo1Application {
@Autowired
BeanB beanb;
public static void main(String[] args) {
SpringApplication.run(Demo1Application.class, args);
}
}
と2 @Service
定義:デモコードを次たとえば、私は、メインの春のブートクラスを持っている
@Service
public class BeanB {
@Autowired
private BeanA beana ;
@PostConstruct
public void init(){
System.out.println("beanb is called");
}
public void printMe(){
System.out.println("print me is called in Bean B");
}
}
@Service
public class BeanA {
@Autowired
private BeanB b;
@PostConstruct
public void init(){
System.out.println("bean a is called");
b.printMe();
}
}
を、私は次の出力があります。
豆aが
と呼ばれているがプリントビーンBで
beanbが
と呼ばれる私の質問は、オートワイヤリングは、上記のシナリオのようなステップで行わステップを取る方法ですか?
printMe()
メソッドbeanb
は、@PostConstruct
を先に呼び出さずに呼び出されますか?
[リンク](https://docs.spring.io/spring/docs/4.1.x/spring-framework-reference/html/beans。 html#beans-dependency-resolution)を循環依存性解決に変換します。 –