404錯誤This application has no explicit mapping for /error, so you are seeing this as a fallback.
阿新 • • 發佈:2021-07-13
今天敲springcloud的時候出現了一個問題
無法訪問網頁,報This application has no explicit mapping for /error, so you are seeing this as a fallback.
翻譯一下就是 —> 此應用程式沒有/error的顯式對映,因此您將其視為一個回退。
上網查閱資料知
出現這個異常的原因有
原因1:
Application啟動類的位置不對.要將Application類放在最外側,即包含所有子包 spring-boot會自動載入啟動類所在包下及其子包下的所有元件
原因2:
在springboot的配置檔案:application.yml或application.properties中關於檢視解析器的配置問題
當pom檔案下的spring-boot-starter-paren版本高時使用:spring.mvc.view.prefix/spring.mvc.view.suffix
當pom檔案下的spring-boot-starter-paren版本低時使用::spring.view.prefix/spring.view.suffix
原因3:控制器的URL路徑書寫問題
@RequestMapping(“xxxxxxxxx”) ,實際訪問的路徑與”xxx”不符合
我仔細檢查了一下我的程式碼
可以排除原因一
然後我又去檢查我的controller訪問層
果然式url寫錯了
以後寫程式碼還是要小心,多注意。