Springboot Whitelabel Error Page problem

I recently learned Springboot for the first time and found that it is easy to use beyond imagination. With maven part-time job, it is a great blessing for programmers. Then I encountered various 404 problems when I used it myself: it is clear that the servlet is running normally, the console does not report any errors, and the webpage is Can't open. Baidu has been unresolved for several hours, and later found some of the reasons, and made the following summary. If there are related reasons in the follow-up, I will add them above for reference.




1.yml format results in

 

The format of the xxx.yml file is relatively strict. The table at the green arrow needs to indicate the attribute of server.port, and a space is required after port: (that is, the position of the red arrow), otherwise the problems described above are prone to occur.

2. Spring Boot annotation scanning problem

When Spring Boot annotation scans, the annotations under packages other than the Application class cannot be scanned, so the modifications are as follows:

1. Put the written packages such as controller and service under the package of the class where the Application is located

2. Add the @ComponentScan (com.mike.controller) annotation to the Application startup class . The package name to be scanned is in the brackets. The package to be scanned and the demo are packages of the same level. The @SpringBootApplication annotation needs to be added to the Application.

Although it is simple, I hope it can help you who are scratching your head like me.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325885381&siteId=291194637