You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot Hello World项目出现Whitelabel Error Page 404问题求助

Spring Boot Hello World项目404错误排查

核心排查方向

  • 包扫描范围:主启动类所在包必须包含Controller类,或通过@ComponentScan显式指定扫描路径。比如主启动类在com.example.demo,Controller不能放在com.example.controller(未手动配置扫描的情况下)。
  • Controller注解校验:确认类上有@RestController/@Controller注解,请求方法上有@GetMapping/@PostMapping等映射注解,且路径拼写无错误(比如不要把/hello写成/hellow)。
  • 依赖完整性:检查pom.xml是否引入spring-boot-starter-web依赖,缺失该依赖会导致Web核心组件无法加载。
  • 配置项检查:
    • 确认server.port配置的端口与访问时一致,比如配置了server.port=8081就不能用8080访问。
    • 若配置了server.servlet.context-path,访问URL必须加上该上下文路径(比如配置/demo,访问路径就是http://localhost:8080/demo/hello)。
  • 启动日志验证:启动项目时查看控制台,确认是否有Controller映射成功的日志(例如Mapping GET /hello to public java.lang.String com.example.demo.HelloController.hello()),无此日志说明Controller未被Spring加载。

需要你提供的代码片段

  • 完整的pom.xml代码
  • Controller类的全部代码
  • 主启动类的全部代码
  • application.properties的配置内容

内容的提问来源于stack exchange,提问作者user18043163

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 02:10:05