原因:spring boot只會掃描啟動類當前包和以下的包
比如以下:
主類:Application放在包com.springboot.main
controller類放在包com.springboot.controller
上面這處情況是找不到controller的
正確的做法是:
Application放在包com.springboot
controller類放在com.springboot.controller,這樣相當於controller的在的包屬於com.springboot底下。