Skip to content

Instantly share code, notes, and snippets.

@rdp
Last active July 17, 2022 20:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdp/6cd55fe35a9f7d1f260995944bd9e0e5 to your computer and use it in GitHub Desktop.
Save rdp/6cd55fe35a9f7d1f260995944bd9e0e5 to your computer and use it in GitHub Desktop.
@Service
class BeanB {
@Autowired
BeanA beana ;
@PostConstruct
public void init(){
System.out.println("bean b init is called a.b=" + beana.b);
}
}
@Service
@DependsOn("beanB")
class BeanA {
@Autowired
BeanB b;
@PostConstruct
public void init(){
System.out.println("bean a init is called b.a=" + b.beana);
}
}
output:
bean a init is called b.a=null
bean b init is called a.b=xxx.BeanB@5c45d770
@Service
class BeanB {
@Autowired
BeanA beana ;
@PostConstruct
public void init(){
System.out.println("bean b init is called a.b=" + beana.b);
}
}
@Service
class BeanA {
@Autowired
BeanB b;
@PostConstruct
public void init(){
System.out.println("bean a init is called b.a=" + b.beana);
}
}
output:
bean b init is called a.b=null
bean a init is called b.a=xxxBeanA@727eb8cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment