1. 程式人生 > >SpringBoot2 Whitelabel Error Page一種可能的解決辦法

SpringBoot2 Whitelabel Error Page一種可能的解決辦法

基於SprintBoot構建一個非常簡單的web 應用,在寫了controller並構造了一個mapping函式以後,啟動在瀏覽器訪問發現,報如下錯誤:

Whitelabel Error Page

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

Sun Sep 23 14:40:17 GMT+08:00 2018
There was an unexpected error (type=Not Found, status=404).
No message available

檢視日誌,發現後臺加入了/error等,但沒有加入我自己構建的mapping
多方查閱資料以後發現,是由springboot掃描方式造成的,入口檔案必須在controller包之上

具體來說,假如入口檔案位置為com.springdemo.demo1,那麼Controller檔案所在類應該放入包com.springdemo.demo1.xx下面

修改以後,訪問成功。
當然,這個估計是可以配置的,以後深入瞭解了以後再補充。