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
    • 问题
    • Root Cause :在SpringBoot的主类XXXApplication.java 添加了@ComponentScan里面配置错误
    • 解决办法有多种
    • Append
    • 参考链接

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

问题

启动SpringBoot的时候访问端口出现该页面;

Root Cause :在SpringBoot的主类XXXApplication.java 添加了@ComponentScan里面配置错误


@ComponentScan(basePackages = {"cn.xxx.xxx.science.dao"})
因此扫描不到Controller的相关内容

解决办法有多种

  1. 去掉这个@ComponentScan,这样XXXApplication.java 会自动扫描 ,spring-boot会自动加载启动类所在包下及其子包下的所有组件。
  2. ComponentScan 配置为XXXApplication.java packages @ComponentScan(basePackages = {"cn.xxx.xxx.science"})

Append

这个错误很常见,我这里只是列出了我所遇到的情况,具体问题具体分析

参考链接

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

你可能感兴趣的:(#,Spring)