Since you mention Config First Bootstrap (https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_client.html#config-first-bootstrap), that means you are using Spring Cloud Config over Spring Cloud Consul Config?
If so, you also need to include
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-consul-discovery</artifactId>
</dependency>
If using Spring Cloud Consul Config instead of Spring Cloud Config (see Difference between spring cloud config server vs consul? and Spring Cloud Consul Config over Spring Cloud Config for discussions on the differences), you may still run into this problem.
Below is for cases when Spring Cloud Consul Config is being used:
There's no mention of the spring cloud version, but looking at version 3.0.0, I see that the bootstrap section of spring.factories used for auto configuration does not include the file ConsulDiscoveryClientConfiguration. This is the Configuration file that exports the DiscoveryClient bean (ConsulDiscoveryClient extends DiscoveryClient).
public class ConsulDiscoveryClientConfiguration {
...
@Bean
@ConditionalOnMissingBean
public ConsulDiscoveryClient consulDiscoveryClient(ConsulClient consulClient,
ConsulDiscoveryProperties discoveryProperties) {
return new ConsulDiscoveryClient(consulClient, discoveryProperties);
}
}
ConsulDiscoveryClientConfiguration is included in the regular # Auto-Configuration section as you can see below, but that phase happens after the # Bootstrap Configuration phase. These are the relevant spring.factories files
org/springframework/cloud/spring-cloud-vault-config/3.0.0/spring-cloud-vault-config-3.0.0.jar!/META-INF/spring.factories
# Auto-Configuration
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.vault.config.VaultReactiveAutoConfiguration,\
org.springframework.cloud.vault.config.VaultAutoConfiguration,\
org.springframework.cloud.vault.config.VaultHealthIndicatorAutoConfiguration
# Bootstrap Configuration
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
org.springframework.cloud.vault.config.DiscoveryClientVaultBootstrapConfiguration,\
org.springframework.cloud.vault.config.ReactiveDiscoveryClientVaultBootstrapConfiguration,\
org.springframework.cloud.vault.config.VaultBootstrapConfiguration,\
org.springframework.cloud.vault.config.VaultReactiveBootstrapConfiguration,\
org.springframework.cloud.vault.config.VaultBootstrapPropertySourceConfiguration
# ConfigData Resolver
org.springframework.boot.context.config.ConfigDataLocationResolver=\
org.springframework.cloud.vault.config.VaultConfigDataLocationResolver
# ConfigData Loader
org.springframework.boot.context.config.ConfigDataLoader=\
org.springframework.cloud.vault.config.VaultConfigDataLoader
org/springframework/cloud/spring-cloud-consul-discovery/3.0.0/spring-cloud-consul-discovery-3.0.0.jar!/META-INF/spring.factories
# Auto-Configuration
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.consul.discovery.configclient.ConsulConfigServerAutoConfiguration,\
org.springframework.cloud.consul.serviceregistry.ConsulAutoServiceRegistrationAutoConfiguration,\
org.springframework.cloud.consul.serviceregistry.ConsulServiceRegistryAutoConfiguration,\
org.springframework.cloud.consul.discovery.ConsulDiscoveryClientConfiguration,\
org.springframework.cloud.consul.discovery.reactive.ConsulReactiveDiscoveryClientConfiguration,\
org.springframework.cloud.consul.discovery.ConsulCatalogWatchAutoConfiguration, \
org.springframework.cloud.consul.support.ConsulHeartbeatAutoConfiguration
# Bootstrap Configuration
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
org.springframework.cloud.consul.discovery.configclient.ConsulDiscoveryClientConfigServiceBootstrapConfiguration
org.springframework.boot.Bootstrapper=\
org.springframework.cloud.consul.discovery.configclient.ConsulConfigServerBootstrapper
As you can see, the # Bootstrap Configuration in spring-cloud-vault-config includes the right Vault Configuration files, but the # Bootstrap Configuration in spring-cloud-consul-discovery only includes ConsulDiscoveryClientConfigServiceBootstrapConfiguration, which seems to be there for cases when someone chooses Spring Cloud Config instead of Spring Cloud Consul Config. I say this because the file is conditional on ConfigServicePropertySourceLocator.class
@ConditionalOnClass(ConfigServicePropertySourceLocator.class)
@ConditionalOnProperty("spring.cloud.config.discovery.enabled")
@Configuration(proxyBeanMethods = false)
@ImportAutoConfiguration({ ConsulAutoConfiguration.class, ConsulDiscoveryClientConfiguration.class,
ConsulReactiveDiscoveryClientConfiguration.class })
public class ConsulDiscoveryClientConfigServiceBootstrapConfiguration {
}
which is found in spring-cloud-config-client-3.0.0.jar. If you were to include the spring-cloud-config-client dependency, Vault service discovery would work, since it includes
@ImportAutoConfiguration({ ... ConsulDiscoveryClientConfiguration.class })
the exact Configuration file needed. The problem is, if you include spring-cloud-config-client, you'd now be using both Spring Cloud Consul Config and Spring Cloud Config, which is likely not what you want (both are enabled by spring.cloud.discovery.enabled, so attempting to include both dependencies and switching one off may be tricky).
Ok, so from what I see above, this looks like a bug in Spring Cloud Consul. I didn't see any other spring.factories that could potentially load ConsulDiscoveryClientConfiguration in the Bootstrap Configuration section. If there exists some other dependency that is needed that will do this, I haven't seen it.
As a temporary workaround until the problem is fixed in Spring Cloud Consul, you can add your own src/main/resources/META-INF/spring.factories file to a module in your project and include
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
org.springframework.cloud.consul.discovery.ConsulDiscoveryClientConfiguration
It solves the problem in spring cloud version 3.0.0.