【发布时间】:2015-06-27 13:26:23
【问题描述】:
最初将此作为问题发布在 GitHub 中,但可能更适合此论坛...
我们正在为在 Eureka 中注册的 Spring Cloud 服务分配一些自定义元数据值,现在我们需要在 Eureka 仪表板中查看这些值。我正在尝试扩展/覆盖 /info 端点,以便我们的元数据可以从 Eureka 仪表板中看到,该仪表板已经提供了到每个注册服务的 /info 端点的超链接。我读过我可以通过将我自己的 bean 版本添加到上下文中来覆盖引导自动配置的 InfoEndpoint。我正在尝试使用以下配置 bean 进行测试:
@Configuration
public class EndpointConfig {
@Bean
public InfoEndpoint infoEndpoint() throws Exception {
LinkedHashMap<String, Object> info = new LinkedHashMap<String, Object>();
info.put("name", "value");
return new InfoEndpoint(info);
}
}
当我运行我的服务并点击它的 /info 端点时,我看不到这个测试值。我也在日志中看到了这一点:
2015-04-17 14:54:23,910 主要信息 DefaultListableBeanFactory - - - - 覆盖 bean 'infoEndpoint' 的 bean 定义:替换 [Root 豆:类[空];范围=;摘要=假;懒惰初始化=假; 自动线模式=3;依赖检查=0;自动接线候选=真; 主要=假; factoryBeanName=endpointConfig; factoryMethodName=infoEndpoint;初始化方法名=空; destroyMethodName=(推断);在类路径资源中定义 [com/acme/ecom/items/config/EndpointConfig.class]] 与 [Root bean: 类[空];范围=;摘要=假;懒惰初始化=假;自动线模式=3; 依赖检查=0;自动接线候选=真;主要=假; factoryBeanName=org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$InfoEndpointRebinderConfiguration; factoryMethodName=infoEndpoint;初始化方法名=空; destroyMethodName=(推断);在类路径资源中定义 [org/springframework/cloud/autoconfigure/RefreshAutoConfiguration$InfoEndpointRebinderConfiguration.class]]
看来我的 infoEndpoint bean 版本正在被另一个来自 Spring cloud 的 bean 替换(org/springframework/cloud/autoconfigure/RefreshAutoConfiguration$InfoEndpointRebinderConfiguration.class)。
我读对了吗?如果是这样,我该如何预防?
谢谢, 比尔
【问题讨论】:
-
目前没有。我们可以让它可配置。
-
谢谢!刚刚将其添加到 spring-cloud-commons 存储库中。