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

View: 11721|Reply: 0

[Source] Springboot @Autowired fails to inject issues

[Copy link]
Posted on 1/8/2019 11:09:37 AM | | |
Special reminder: Be sure to pay attention to the file structure

The WebAppApplication must be at the outermost layer of the package, otherwise Spring will not be able to host all classes, which will cause @Autowired to fail to inject.

1. Add a tool class to get the beans hosted in Spring

(1) Tools

(2) Use

1) When the program starts, instantiate the SpringContextUtil

or
2) In the method using @Service, use SpringcontexUtil to get the bean context through @Autowired injection

When I am new to Java, I don't understand the principles very thoroughly, and I only record the problems I encounter, and modify them at any time as I learn deeper





Previous:The strongest brain - Shen Yifan Super Memory Class
Next:I don't want to gamble for the rest of my life
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