[Solved] SpringBoot Error: This application has no explicit mapping for /error,so you are seeing this as a fallback

[problem phenomenon]

In springboot, when there is no error in the request link and the controller configuration, an error will be prompted when accessing a controller link interface:


This application has no explicit mapping for /error,so you are seeing this as a fallback

[reason]

The request cannot find the corresponding bean for processing. If there is no error in the request link and the controller configuration, it may also be the problem of springbootapplication package scanning, as follows:

By default, the @springbootapplication annotation will only the beans of this package and its sub-packages, resulting in the corresponding controller beans not being loaded into the spring container

[solution]

Scheme I:

Move all controller classes to the same level package or sub package of application class, as shown in the figure:

Scheme II:

If you don’t want to change the file location, you can specify the scanned package with the @ springbootapplication annotation:


@SpringBootApplication(scanBasePackages="com.kid")

Read More: