This article is a mirror article of machine translation, please click here to jump to the original article.

View: 13323|Reply: 2

[Source] Spring Boot looks at all registered BEANs

[Copy link]
Posted on 3/23/2022 9:45:28 AM | | | |
In spring boot, @Component, @Repository, @Controller, @Service, @Configration annotations convert the object you want to instantiate into a bean and put it in an IoC container, so you can say that everything is a BEAN.

When we need to use an object, we can get the BEAN from the IOC container by constructor injection or by using @Autowired annotations. When we get a BEAN that has not been injected, we may get an error when starting the project. Sometimes when a BEAN is obtained dynamically, no error will be reported when starting, but an error may be reported when running. So, getting to see all registered BEAs is very helpful for us to troubleshoot problems.

The help class code for dynamically obtaining BEAN in a spring container is as follows:

View all registered BEAN codes as follows:

The renderings are as follows:







Previous:ASP.NET Core redirect a tag parameter carries the current URL
Next:Query the remote address of the current project's Git
Posted on 3/23/2022 5:32:14 PM |
Learn to learn...
Posted on 5/23/2022 8:26:21 AM |
Learn to learn
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com