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

访问测试项目路径localhost:8080/hello 后台抛出异常:This application has no explicit mapping for /error, so you are seeing this as a fallback.

抛出此异常表示访问的页面url没有匹配到对应的值,原因有如下三点:

  • Application启动类的位置不对:要将Application类放在最外侧,即包含所有子包 ,spring-boot会自动加载启动类所在包下及其子包下的所有组件。如下图所示:

                           异常:This application has no explicit mapping for /error, so you are seeing this as a fallback._第1张图片

  • springboot的配置文件有误:关于application.yml或application.properties文件中视图解析器的配置问题。在pom文件下的spring-boot-starter-paren版本较高时使用以下配置:spring.mvc.view.prefix/spring.mvc.view.suffix,当pom文件下的spring-boot-starter-paren版本较低时使用以下配置:spring.view.prefix/spring.view.suffix。
  • 控制器的url访问路径与注解@GetMapping("/xxxx")不匹配,如下图所示:

异常:This application has no explicit mapping for /error, so you are seeing this as a fallback._第2张图片

异常:This application has no explicit mapping for /error, so you are seeing this as a fallback._第3张图片

你可能感兴趣的:(常见问题)