SpringBoot入门报错 Whitelabel Error Page的总结

刚入门SpringBoot,编写helloControl类,去访问本地端口,无缘无故报了这个错误 Whitelabel Error Page

在这里插入图片描述
总结了下,目前我碰到的有三种会导致这种情况

1、当你的 SpringBootApplication 没有在最外层包的时候,会报该错,把它放在最外层重新运行试下。
PS: control 类的文件最好单独卸载一个包里,不要和 SpringBootApplication 放在一块
在这里插入图片描述
2、类上面注解要写成 @RestController,不要写成 @Controller;还有 方法上面的 @RequestMapping注解里面的name属性改成value试下 @RequestMapping(value="/hello",method = RequestMethod.GET) (新版本的好像把 name 改成 value 属性了)
在这里插入图片描述
3、或者你在 application.properties 配置文件里加了项目前缀属性,server.context-path 不适用于2.0.0之后的版本,得改成 server.servlet.context-path
在这里插入图片描述

还有其他导致该错误的欢迎大佬补充。。。

猜你喜欢

转载自blog.csdn.net/hyx1249273846/article/details/105927605