I am trying to build my own DiscoveryClient
that would use Docker Swarm as the service source. I got it working with Spring Cloud Gateway and Spring Cloud Loadbalancer already. However, when I tried to use it to do discovery for the configserver
by setting spring.cloud.config.discovery.enabled=true
I get the following error
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: {}
I have created AutoConfigure classes as well but no luck. The project is here https://github.com/trajano/spring-cloud-demo.
When looking at the debug logs, with and without the discovery, it appears that the AutoConfiguration
beans do not load up in the CONDITIONS EVALUATION REPORT specifically the ones in other libraries.
Similar to Spring cloud discovery first does not work at all but they are using Eureka, whereas I am trying to determine how to build my own DiscoveryClient.
There was a separate set of org.springframework.boot.autoconfigure.EnableAutoConfiguratio
elements in spring.factory
called org.springframework.cloud.bootstrap.BootstrapConfiguration
So I added this
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
net.trajano.spring.swarm.discovery.DockerSwarmDiscoveryClientConfigServiceBootstrapConfiguration
And this class
@ConditionalOnClass(ConfigServicePropertySourceLocator.class)
@ConditionalOnProperty("spring.cloud.config.discovery.enabled")
@Configuration(proxyBeanMethods = false)
@Import({
DockerSwarmDiscoveryClientAutoConfiguration.class,
// this emulates
// @EnableDiscoveryClient, the import
// selector doesn't run before the
// bootstrap phase
DockerClientConfiguration.class,
DockerSwarmDiscoveryAutoConfiguration.class,
DockerSwarmReactiveDiscoveryClientAutoConfiguration.class,
ReactiveCommonsClientAutoConfiguration.class
})
public class DockerSwarmDiscoveryClientConfigServiceBootstrapConfiguration {
}