【SpringBoot】This application has no explicit mapping for /error,so you are seeing this as a fallback 您所在的位置:网站首页 defrijet500 【SpringBoot】This application has no explicit mapping for /error,so you are seeing this as a fallback

【SpringBoot】This application has no explicit mapping for /error,so you are seeing this as a fallback

2024-07-01 02:00| 来源: 网络整理| 查看: 265

【问题现象】

SpringBoot中,在请求链接无错误、Controller配置无错误的情况下,访问某个Controller链接接口时,提示错误:

This application has no explicit mapping for /error,so you are seeing this as a fallback

在这里插入图片描述

【原因】

请求无法找到对应的bean进行处理,在请求链接无错误、Controller配置无错误的情况下,还可能是SpringBootApplication包扫描的问题,如下:

@SpringBootApplication注解默认只会将本包及子包的bean,导致对应的Controller bean没有被加载到Spring容器中容器内 在这里插入图片描述

【解决】 方案一:

将所有Controller类移动到Application类同级包或者子包中,如图: 在这里插入图片描述

方案二:

如果不想改变文件位置,则可将@SpringBootApplication注解指定扫描的包:

@SpringBootApplication(scanBasePackages="com.kid")

在这里插入图片描述



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有