- 前言
- 方法
- 测试程序
一般出现这种问题
Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Tue Oct 19 20:54:25 CST 2021 There was an unexpected error (type=Not Found, status=404). No message available
如图所示
方法问题的解决方法
一般需要通过编辑器的bug出错点寻找
如果是编辑正常缺打不开网址
一般都是目录设置或者是一些小细节
- 具体目录的设置
SpringBoot的启动类与controller包要在同一个目录或者同一级目录下
- 注解有无正常错误
SpringBoot的启动类(类名上面有@SpringBootApplication注解 )
- 配置文件的格式以及版本问题或者时依赖文件有无添加正确
以上基本都可以排查错误
测试程序如果还执行出错
具体可以一步一步排查
简单的实战排查小程序
可看博主这个无错误的,是否还会出错
依赖文件
org.springframework.boot spring-boot-starter-parent 2.2.5.RELEASE com.manongyanjiuseng.springboot 002-springboot-springmvc 1.0.0 1.8 spring-milestones Spring Milestones https://repo.spring.io/milestone false org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.junit.vintage junit-vintage-engine junit junit test org.springframework.boot spring-boot-maven-plugin
控制层类
@Controller
public class IndexController {
@RequestMapping(value = "/springboot/say")
public @ResponseBody String say() {
return "Hello,SpringBoot!";
}
}
启动入口类
//SpringBoot项目启动入口类
@SpringBootApplication //开启springboot配置
public class Application {
//springboot项目代码必须放到Application类所在的同级目录或下级目录
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
启动成功之后
在网页打开相应的网址http://localhost:8080/springboot/say
就会出现



