springcloud微服务 - 集成Zuul网关 无法通过网关

springcloud微服务 - 集成Zuul网关 无法通过网关

今天上午配置了下zuul网关,结果无法通过网关。具体如下:
下面先贴下我做的动作。
1、application.yml文件:

server:
  port: 9004

eureka:
  instance:
    hostname: 127.0.0.1
  client:
    service-url:
      defaultZone: http://${
   eureka.instance.hostname}:9000/eureka
    register-with-eureka: true
    fetch-registry: true

spring:
  #profiles:
  #active: dev
  application:
    name: zuul

#路由规则定义。这里定义两种路由规则route1和route2#,代表访问网关/test01/**或/test02/**时。
#路由到服务名为 eurekaclient1或 eurekaclient2中的服务集群去。
zuul:
  routes:
    route1:
      path: /test01/**
      serviceId: eurekaclient1
    route2:
      path: /test02/**
      serviceId: eurekaclient2

2、pom文件:


        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-starter-netflix-zuulartifactId>
            <version>2.2.8.RELEASEversion>
        dependency>

3、启动类添加注解:

@SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy
public class ZuulApplication {
   

    public static void main(String[] args) {
   
        SpringApplication.run(ZuulApplication.class, args);
    }

}

搞完这几步,启动全部服务。首先访问注册中心,已确认全部服务已经注册到注册中心,eurekaclient1、eurekaclient2中都有个返回值为该服务的服务名称的接口“/server”。但是当通过网关“http://localhost:9004/test01/server”访问eurekaclient1和eurekaclient2,却发现一直报如下错误:

java.lang.NoSuchMethodError: org.springframework.boot.web.servlet.error.ErrorController.getErrorPath()Ljava/lang/String;
	at org.springframework.cloud.netflix.zuul.web.ZuulHandlerMapping.lookupHandler(ZuulHandlerMapping.java:87) ~[spring-cloud-netflix-zuul-2.2.8.RELEASE.jar:2.2.8.RELEASE]
	at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.getHandlerInternal(AbstractUrlHandlerMapping.java:152) ~[spring-webmvc-5.3.7.jar:5.3.7]
	at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:498) ~[spring-webmvc-5.3.7.jar:5.3.7]
	at org.springframework.web

你可能感兴趣的:(springcloud微服务,Zuul网关,java,微服务,微服务架构,cloud)