Spring Cloud报错之This application has no explicit mapping for /error, so you are seeing this as a f...

路由网关(zuul)服务的时候出了This application has no explicit mapping for /error, so you are seeing this as a fallback.

原因1:

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

原因2:

在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

原因3:

控制器的URL路径书写问题
@RequestMapping(“xxxxxxxxxxxxxx”)
实际访问的路径与”xxx”不符合.

结果是我写错了serviceId。。。。

spring:
  application:
    name: server-ribbon//这个没和zuul服务中的路由配置中的serviceId匹配,改成service-ribbon就行
zuul:
  routes:
    api-a:
      path: /api-a/**
      serviceId: service-ribbon//
    api-b:
      path: /api-b/**
      serviceId: service-feign

这个没和zuul服务中的路由配置中的serviceId匹配,改了重启之后就好了
尴尬

你可能感兴趣的:(Spring Cloud报错之This application has no explicit mapping for /error, so you are seeing this as a f...)