This application has no explicit mapping for /error

Deng Steve picture Deng Steve · Jun 30, 2015 · Viewed 401.3k times · Source

I used maven to do the tutorial https://spring.io/guides/gs/uploading-files/
All the codes I used was copied.

The Application can run, but I get the error:

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Tue Jun 30 17:24:02 CST 2015 There was an unexpected error (type=Not Found, status=404). No message available

How can I fix it?

Answer

vignesh Subash picture vignesh Subash · Aug 18, 2016

Make sure that your main class is in a root package above other classes.

When you run a Spring Boot Application, (i.e. a class annotated with @SpringBootApplication), Spring will only scan the classes below your main class package.

com
   +- APP
         +- Application.java  <--- your main class should be here, above your controller classes
         |
         +- model
         |   +- user.java
         +- controller
             +- UserController.java