我有一个带有以下spring包版本的spring cloud服务
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.4.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Brixton.SR4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>1.3.7</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>1.3.7</version>
</dependency>
我的弹簧启动管理服务器ui在9003端口运行。我正在使用eureka发现客户端将我的终点注册到注册服务。
我的服务的application.yml包含以下配置。
server:
context-path: /myservice
port: 0
management:
context-path: /mng
security:
enabled: false
eureka:
instance:
preferIpAddress: true
statusPageUrlPath: ${server.context-path:}${management.context-path:}/info
healthCheckUrlPath: ${server.context-path:}${management.context-path:}/health
client:
serviceUrl:
defaultZone: http://${EUREKA_DNS:localhost}:8761/eureka/
当我开始服务时,我可以看到有关我的api端点的以下日志
2018-01-11 16:01:22.176 INFO 6070 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mng/health || /mng/health.json],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(java.security.Principal)
2018-01-11 16:01:22.177 INFO 6070 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mng/info || /mng/info.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-11 16:01:22.177 INFO 6070 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mng/mappings || /mng/mappings.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-11 16:01:22.177 INFO 6070 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mng/metrics/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2018-01-11 16:01:22.178 INFO 6070 --- [ main] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mng/metrics || /mng/metrics.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
当我在打印映射信息日志后启动仪表板时
2018-01-11 22:04:00.886 INFO 55 --- [tp1976870338-18] o.s.c.n.zuul.web.ZuulHandlerMapping : Mapped URL path [/api/applications/c5a746b1/health/**] onto handler of type [class org.springframework.cloud.netflix.zuul.web.ZuulController]
2018-01-11 22:04:00.886 INFO 55 --- [tp1976870338-18] o.s.c.n.zuul.web.ZuulHandlerMapping : Mapped URL path [/api/applications/c5a746b1/env/**] onto handler of type [class org.springframework.cloud.netflix.zuul.web.ZuulController]
2018-01-11 22:04:00.886 INFO 55 --- [tp1976870338-18] o.s.c.n.zuul.web.ZuulHandlerMapping : Mapped URL path [/api/applications/c5a746b1/metrics/**] onto handler of type [class org.springframework.cloud.netflix.zuul.web.ZuulController]
我现在的问题是当我打开我的仪表板Ui时,它正试图从“/ api / applications / c5a746b1 / metrics”获取指标信息,但它返回404错误。但是在浏览器中我手动输入“/ myservice / mng / metrics”时,我可以看到指标信息。
我是春天云的新手,任何帮助表示赞赏。
提前致谢
答案 0 :(得分:0)
您应该更新到1.4.x并在服务中添加mangament.context-path
条目&#39;元数据。这样,SBA服务器就知道执行器端点的正确路径。