1. 程式人生 > >Spring boot掃描不到controller註解

Spring boot掃描不到controller註解

今天準備玩一下Spring boot,工程搭建好後,但是hello world一直出不來,404錯誤

Whitelabel Error Page

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

捉摸了半天,原因是Spring boot的啟動類application的位置問題


DemoApplication就是啟動類,它必須放在和有註解的類的同一目錄或者父目錄才能掃描到註解類。