我正在使用spring cloud设置spring boot管理员.现在我已经建立了一个独立的eureka服务器和一个spring boot管理员和一些spring boot应用程序作为管理员客户端.如果我没有为所有客户端设置management.context-path,一切正常.但是现在我需要监控所有客户端(一些客户端没有management.context-path,一些客户端不同management.context-path).我知道我应该使用元数据来实现这一点,但在阅读相关文档后,我仍然可以完成这项工作.以下是我在客户端和管理员端的配置.
客户端:
spring:
application:
instance_id: user
name: microservice-provider-user
management:
context-path: '/mgmt'
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
instance:
preferIpAddress: false
statusPageUrlPath: ${management.context-path}${endpoints.info.path:/info}
healthCheckUrlPath: ${management.context-path}${endpoints.health.path:/health}
metadata-map:
instanceId:
${spring.application.name}:${spring.application.instance_id:${random.value}}
Run Code Online (Sandbox Code Playgroud)
管理员方面:
spring:
application:
name: wahaha-admin
boot:
admin:
routes:
endpoints: env,metrics,trace,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,hystrix.stream,turbine.stream
url: http://${HOST_NAME:localhost}:${server.port}
discovery:
converter.management-context-path: '/mgmt'
Run Code Online (Sandbox Code Playgroud)
问题:
spring.boot.admin.discovery.converter.management-context-path为/mgmt,该值与客户端相同,这只有在我将所有客户端应用程序设置为相同值时才能正常工作,这是不可能的.我该怎么做才能支持不同的management.context-path?PS:我在本地桌面上没有在任何公共云上完成所有这些操作,并且稍后将转移到产品环境(仍然不使用公共云).
我是一个Spring引导应用程序,在一个自动配置类中已经创建了一个bean,它来自一个依赖的jar,如bellow:
@Bean
@Order(100)
public StaticRouteLocator staticRouteLocator(AdminServerProperties admin) {
Collection<ZuulRoute> routes = Collections
.singleton(new ZuulRoute(admin.getContextPath() + "/api/turbine/stream/**",
properties.getUrl().toString()));
return new StaticRouteLocator(routes, server.getServletPrefix(), zuulProperties);
}
Run Code Online (Sandbox Code Playgroud)
现在我想替换这个bean,但我仍然需要这个有不必要的Bean创建的jar.所以我在我的主要自动配置类中添加了另一个bean创建方法,如下所示:
@Bean(name="patchedStaticRouteLocator")
@Order(10)
@Primary
@ConditionalOnMissingBean
public StaticRouteLocator patchedStaticRouteLocator(AdminServerProperties admin) {
Collection<ZuulProperties.ZuulRoute> routes = Collections
.singleton(new ZuulProperties.ZuulRoute(admin.getContextPath(),
properties.getUrl().toString()));
return new StaticRouteLocator(routes, server.getServletPrefix(), zuulProperties);
}
Run Code Online (Sandbox Code Playgroud)
但是这无法替换目标bean.错误消息清晰易懂:
org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.cloud.netflix.zuul.filters.RouteLocator] is defined: more than one 'primary' bean found among candidates: [routeLocator, patchedStaticRouteLocator, staticRouteLocator, compositeRouteLocator, applicationRouteLocator]
Run Code Online (Sandbox Code Playgroud)
我的问题是什么是在春季靴子中更换这种现有豆子的正确方法?提前致谢.
我有这个二进制字符串,我试图转换为普通字符串.
[b'\xe4\xba\xba\xe4\xba\xba\xe7\xbd\x91\xef\xbc\x8c\xe4\xb8\xad\xe5\x9b\xbd\xe9\xa2\x86\xe5\x85\x88\xe7\x9a\x84\xe5\xae\x9e\xe5\x90\x8d\xe5\x88\xb6SNS\xe7\xa4\xbe\xe4\xba\xa4\xe7\xbd\x91\xe7\xbb\x9c\xe3\x80\x82\xe5\x8a\xa0\xe5\x85\xa5\xe4\xba\xba\xe4\xba\xba\xe7\xbd\x91\xef\xbc\x8c\xe6\x89\xbe\xe5\x88\xb0\xe8\x80\x81\xe5\x90\x8c\xe5\xad\xa6\xef\xbc\x8c\xe7\xbb\x93\xe8\xaf\x86\xe6\x96\xb0\xe6\x9c\x8b\xe5\x8f\x8b\xe3\x80\x82']
Run Code Online (Sandbox Code Playgroud)