DiscoveryClient unavailable during Bootstrap Configuration
See original GitHub issueWe’re in the process of upgrading to Spring Boot 2 and Finchley from 1.5 and Dalston, and we’re making use of the spring.cloud.vault.discovery.enabled=true
property, so as to lookup Vault’s location through Consul’s service discovery mechanism, however starting the service now throws an exception from DiscoveryClientVaultBootstrapConfiguration
as there is no availableDiscoveryClient
:
Error creating bean with name 'discoveryClientVaultBootstrapConfiguration': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.client.discovery.DiscoveryClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
We had this working previously using 1.5.8 of Spring Boot, Dalston.SR5 of Spring Cloud, and we were using 1.1.0-RELEASE of Spring Cloud Vault Config and 1.0.0 of Spring Vault Core to provide the discovery capability. We’ve found that using these versions but with Spring Cloud Edgware.RELEASE leads to the missing DiscoveryClient
, so not due to Spring Boot 2 / Finchley specifically.
If Spring Cloud Config is included, enabled and its discovery property enabled then a DiscoveryClient
implementation is available to the DiscoveryClientVaultBootstrapConfiguration
when using Edgware and the application starts up correctly, so we presume there is some missing auto configuration for using Consul as the DiscoveryClient
with Vault.
Alternatively, we may be completely misunderstanding how to configure these things correctly!
Reproduce
bootstrap.yml
spring:
cloud:
vault:
discovery:
enabled: true
consul:
discovery:
enabled: true
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Edgware.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-vault-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (6 by maintainers)
Top GitHub Comments
Great work.
@ConditionalOnClass(VaultPropertySourceLocatorSupport.class)
isn’t really required,spring.cloud.vault.discovery.enabled
is sufficient.Spring Cloud Consul is going to remove their
@ConditionalOnClass
so there’s no need to file a PR right now.With the migration to Spring Boot’s ConfigData API we’re changing how resources during config subsystem initialization are configured and obtained. We’re not going to touch the Bootstrap configuration support anymore and closing this ticket in favor of #487.