Last active
July 17, 2022 20:02
-
-
Save rdp/6cd55fe35a9f7d1f260995944bd9e0e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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