Zuul网关服务器未显示任何路由



我已经创建了一个网关服务器,并在Eureka注册了它。下面是引导程序类:

@SpringBootApplication
@EnableZuulServer
@EnableDiscoveryClient
public class GatewayServerApplication {
...
}

我已经集成了Zuul网关服务器和Eureka服务器。一切都很顺利。Eureka成功启动,网关服务器也成功启动。尽管如此,我在进入路线时遇到了困难。下面是我试图访问的链接:

https://localhost:5555/actuator/routes

请帮我解决这个问题。

提前谢谢。

p.S我在application.properties文件中的网关服务器配置信息:

#Application
server.port=5555
#Eureka
cloud.config.enabled=true
eureka.instance.preferIpAddress=true
eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka-server/

#Actuator
management.endpoints.web.exposure.include=*
management.security.enabled=false

@EnableZuulServer更改为@EnableZuulProxy,如下所示:

@SpringBootApplication
@EnableZuulProxy
@EnableDiscoveryClient
public class GatewayServerApplication {
...
}

创建Zuul Gateway Server有两个选项:

  • 第一个是使用@EnableZuulServer注释。此注释创建了一个Zuul服务器,但不提供Zuul预构建的路由功能。当您想要构建自己的路由服务时,可以使用此注释。

  • 第二个选项是使用@EnableZuulProxy注释。此注释创建Zuul Server,加载Zuul反向代理过滤器,并自动使用Eureka Server根据服务ID查找服务,然后使用Netflix Ribbon对来自Zuul的请求进行客户端负载平衡。

我认为在您的情况下更适合使用@EnableZuulProxy注释,因为您不想构建自己的自定义服务。

最新更新