springboot正常啓動但訪問404

spring boot正常啓動了,但是瀏覽器一直報404.,原因是spring boot只會掃描啓動類當前包和以下的包  。 如果將 spring boot 放在 包  com.example.controller 裏面的話 ,它會掃描 com.example.controller 和 com.example.controller.* 裏面的所有的 ;

還有一種解決方案是 在啓動類的上面添加 @ComponentScan(basePackages = {"com.example.*"})

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章