Spring Cloud zuul "path": "/actuator/routes" 404 not found

标签 spring cloud netflix-zuul

我使用 Spring Cloud,我想配置 Zuul

zuul服务的application.yml为

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

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

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

但是当我运行 url 时

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?

最佳答案

默认情况下,只有 /health/info 端点是公开的。

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

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

所以对于 yaml 文件:

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

或者如果您只想曝光路线:

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

/actuator/routes 将可用。

关于 Spring Cloud zuul "path": "/actuator/routes" 404 not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57242507/

相关文章:

java - 替换所有服务的 ConfigurationBaseServerList

java - 后调用的 CORS 请求无效?

java - Spring security - oauth2 资源服务器测试

javascript - 通过云作业解析云删除行

java - 启动时的 Liquibase 迁移无法使用 Spring-Boot

sql - 在云上选择正确的数据库 Azure SQL

amazon-s3 - 使用 GET、PUT 方法在 Amazon S3 云中获取和存储对象时,数据大小有哪些限制?

microservices - API 网关模式和 BFF 之间有区别吗?

java - 如何从静态主方法依赖注入(inject)运行时参数

spring - 为 Spring-boot 应用程序捕获应用程序停止事件