Your ApplicationContext is unlikely-to-start due to a @ComponentScan of the default package

Source: Internet
Author: User

1, in the construction of Springboot framework encountered problems.

* * WARNING *: Your ApplicationContext is unlikely-to-start due to a @ComponentScan of the default package.

Warning: Your app context might not start because you added the annotations to the default package. There is also a sentence in the following stack message that includes this meaning.

...... This can also happen if is @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the DEFA Ult package by mistake).

(There are other errors when you start, but only the errors associated with this are extracted.) )

2. My project structure is like this (I built the application file in the Java folder below)

3. Reason Analysis

I'm not using @componentscanning annotations, why is there such an annotation?

Springboot when writing the startup class (the class where the Main method resides), if you do not use @componentscan to indicate the object scan scope, the default is to scan the object in the package that contains the current startup class.

(Note: I did not add @componentscan annotations when I wrote the Main method, so that he would scan the objects in the package where application is located)
If the current startup class does not have a package, it will get an error at startup: Your ApplicationContext is unlikely to start due to a @ComponentScan of the default packages.

(Note: The application class that is written in the Java folder is not subordinate to any one package, so the startup class does not have a package)

4. Solutions

Method One, the application is built under the other packages

Method Two, add @componentscan annotation on the application class, specify the package to be scanned

Reference documents

http://blog.csdn.net/u012834750/article/details/65942092

Your ApplicationContext is unlikely-to-start due to a @ComponentScan of the default 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.