Solve the problem that the SpringBoot project cannot access the Controller

Problem Description:

Solve the problem that the SpringBoot project cannot access the Controller
. Access to the server through the browser displays a 404. This application has no explicit mapping for /error, so you are seeing this as a fallback.
Insert picture description here


Cause Analysis:

The SpringBootApplication.class file is not in the same level directory as the controller package. The @SpringBootApplication annotation in the SpringBootApplication.class file will scan all files under the package where the class is located, and can identify the Controller. If it is placed in another package, it will not be scanned Controller
Insert picture description here


solution:

The SpringBootApplication.class file and the controller package can be placed in the same directory
Insert picture description here

Guess you like

Origin blog.csdn.net/Evain_Wang/article/details/108888820