gpt4 book ai didi

java - 自定义 DiscoveryClient 用于发现 Spring Cloud Config 服务器

转载 作者:行者123 更新时间:2023-12-01 17:15:19 26 4
gpt4 key购买 nike

我正在尝试构建自己的 DiscoveryClient ,它将使用 Docker Swarm 作为服务源。我已经让它与 Spring Cloud Gateway 和 Spring Cloud Loadbalancer 一起使用。但是,当我尝试通过设置 spring.cloud.config.discovery.enabled=true 使用它来发现 configserver 时,出现以下错误

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.client.discovery.DiscoveryClient' available: expected at l
east 1 bean which qualifies as autowire candidate. Dependency annotations: {}

我也创建了 AutoConfigure 类,但没有运气。项目在这里https://github.com/trajano/spring-cloud-demo .

在查看调试日志时,无论是否有发现,AutoConfiguration beans 似乎都没有加载到条件评估报告中,特别是其他图书馆。

类似于Spring cloud discovery first does not work at all但他们正在使用 Eureka,而我正在尝试确定如何构建我自己的 DiscoveryClient。

最佳答案

我看到你的Configuration class for the DiscoveryClient有这些注释:

@ConditionalOnDiscoveryEnabled
@ConditionalOnBlockingDiscoveryEnabled
@ConditionalOnDockerSwarmDiscoveryEnabled
@AutoConfigureAfter({
DockerSwarmDiscoveryAutoConfiguration.class
})
@AutoConfigureBefore({
SimpleDiscoveryClientAutoConfiguration.class,
CommonsClientAutoConfiguration.class
})

难道这些设置没有启用?您提到您启用了发现,但没有提到其他 ConditionOnX 配置。如果未启用它们,bean 将不会加载。

关于java - 自定义 DiscoveryClient 用于发现 Spring Cloud Config 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61401753/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com