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

今天做SpringBoot Demo,遇到了这种错误:

Whitelabel Error Page

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

Sun Aug 19 11:46:45 CST 2018

There was an unexpected error (type=Not Found, status=404).

No message available

 

项目目录结构如下:

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

图中显示创建springboot项目自带的这两个的文件要注意把他俩拿出来放到父包下面也就是图中这个位置。如果你的这两个文件在子包里或者说平级的一个包里就会影响controller无法被扫描到,从而导致无法访问到你的方法。

正确放置:

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