about issues that springboot beans cannot inject (related to package location) Change the automatically scanned package

Source: Internet
Author: User

cause : When the bean is added to the project, @component cannot be scanned by spring (the idea will not be able to get the corresponding bean at compile time).
Later, the research was related to the location of the document package.

Springboot Bean Assembly Rules:
Scan from top to bottom according to the package location where the application class is located!
Scan the package of the application class and its child packages

Note: You can specify a scanned package by adding @componentscan (basepackages={"xxx.xxx", "xxx.xxx"}) to the application class, but the package will not be scanned under the default scan application class once specified

about issues that springboot beans cannot inject (related to package location) Change the automatically scanned package

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.