SpringBoot正常启动,访问项目报404的解决方案。

首先需要检查:
启动类是否放在所有包的父目录;
或者启动类增加注解@ComponentScan(basePackages={"com.demo.test.*"})
其次:
在Controller中,使用@RestController注解;
或者使用@Controller注解类,并且使用@ResponseBody注解方法
最后:
检查配置文件是否有server.context-path=/hello 配置,如果有则访问地址需要ip:port/hello的方式访问。

posted @ 2020-08-05 15:44  小小短腿儿  阅读(2898)  评论(0编辑  收藏  举报