Reputation: 59
I hope they will be executed in the specified order, but the execution result is random,Use @order invalid,Each method is independent, temporarily unable to put it in one method
Upvotes: 0
Views: 740
Reputation: 11
Try this
public void method1() {
System.out.println("method 1");
}
public void method2() {
System.out.println("method 2");
}
public void method3() {
System.out.println("method 3");
}
@PostConstruct
public void postConstruct() {
method1();
method2();
method3();
}
result:
method 1
method 2
method 3
Upvotes: 0
Reputation: 59
@Bean
public void test1(){
System.out.println("bean A init");
}
@Bean
@DependsOn("test1")
public void test2(){
System.out.println("test2");
}
@Bean
@DependsOn("test2")
public void test3(){
System.out.println("test3");
}
You can use this scenario to control the loading order
Upvotes: 1