spring cloud zuul “path”: “/actuator/routes” 404 not found

只谈情不闲聊 提交于 2020-06-08 20:01:32

问题


I work with Spring Cloud and I want to configure Zuul

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'**

But when I run the url

http://192.168.1.41:5555/actuator/routes

I get the message

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

And in the console the messsage is

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

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


回答1:


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

So for a yaml file:

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

or if you only want exposure routes:

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

/actuator/routes will be available.



来源:https://stackoverflow.com/questions/57242507/spring-cloud-zuul-path-actuator-routes-404-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!