弹簧云zuul“路径":"/actuator/routes"找不到404 [英] spring cloud zuul "path": "/actuator/routes" 404 not found

查看:285
本文介绍了弹簧云zuul“路径":"/actuator/routes"找不到404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与Spring Cloud合作,并且想要配置Zuul

I work with Spring Cloud and I want to configure Zuul

zuul服务的application.yml是

application.yml of zuul service is

server:
  port: 5555

  #Setting logging levels
logging:
    level:
      com.netflix: WARN
      org.springframework.web: WARN
      com.thoughtmechanix: DEBUG

eureka:
  instance:
    preferIpAddress: true
  client:
    registerWithEureka: true
    fetchRegistry: true
    serviceUrl:
        defaultZone: http://localhost:8761/eureka/
zuul:
  prefix:  /api
  routes:
    organizationservice: /organization/**
    licensingservice: /licensing/**

启动应用程序时,我会在控制台中看到

When I start the application, I see in the console

zuulserver_1             | 2019-07-28 15:25:30.871  INFO 29 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 5555
zuulserver_1             | 2019-07-28 15:25:30.910  INFO 29 --- [           main] c.t.zuulsvr.ZuulServerApplication        : Started ZuulServerApplication in 99.792 seconds (JVM running for 104.442)
specialroutes-service_1  | 2019-07-28 15:25:33.222  INFO 29 --- [           **main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
organizationservice_1    | 2019-07-28 15:25:33.936  INFO 30 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'**

但是当我运行网址

http://192.168.1.41:5555/actuator/routes

我收到消息

{
    "timestamp": "2019-07-28T15:32:14.254+0000",
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/actuator/routes"
}

在控制台中,消息是

zuulserver_1             | 2019-07-28 15:48:36.494  INFO 28 --- [nio-5555-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
zuulserver_1             | 2019-07-28 15:48:36.624 DEBUG 28 --- [nio-5555-exec-1] c.t.zuulsvr.utils.UserContextFilter      : Special Routes Service Incoming Correlation id: null

我必须如何配置Zuul才能使用/actuator/routes?

How I have to configure Zuul to use /actuator/routes?

推荐答案

默认情况下,仅公开/health/info端点.

By default only the /health and /info endpoints are exposed.

如文档所示,您需要公开端点:

As the documentation indicates, you need to expose the endpoints:

https://github .com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide#endpoints

对于Yaml文件:

management: 
  endpoints: 
    web: 
      exposure: 
        include: '*'

或者如果您只想曝光routes:

management: 
  endpoints: 
    web: 
      exposure: 
        include: 'routes'

/actuator/routes将可用.

这篇关于弹簧云zuul“路径":"/actuator/routes"找不到404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆