栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

springboot出现Whitelabel Error Page This application has no explicit mapping for /error解决方案

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

springboot出现Whitelabel Error Page This application has no explicit mapping for /error解决方案

目录
  • 前言
  • 方法
  • 测试程序

前言

一般出现这种问题

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出错点寻找
如果是编辑正常缺打不开网址
一般都是目录设置或者是一些小细节

  1. 具体目录的设置

SpringBoot的启动类与controller包要在同一个目录或者同一级目录下

  1. 注解有无正常错误

SpringBoot的启动类(类名上面有@SpringBootApplication注解 )

  1. 配置文件的格式以及版本问题或者时依赖文件有无添加正确

以上基本都可以排查错误

测试程序

如果还执行出错
具体可以一步一步排查
简单的实战排查小程序
可看博主这个无错误的,是否还会出错

依赖文件


    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
就会出现

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/336739.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号