question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DiscoveryClient unavailable during Bootstrap Configuration

See original GitHub issue

We’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:closed
  • Created 5 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mp911decommented, Jul 4, 2018

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.

0reactions
mp911decommented, Sep 21, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

7. Spring Cloud Config Client
If you use a `DiscoveryClient implementation, such as Spring Cloud ... If you expect that the config server may occasionally be unavailable when...
Read more >
Spring Cloud Config Eureka-first approach not working
1. You need the eureka serviceUrl in the bootstrap. · That was it! By moving the eureka configuration in myapp-service-test from application.
Read more >
Spring Cloud Eureka Service Discovery implementation ...
Then in our application class, we have to enable the discovery client. ... The “Config First Bootstrap” is the default in Spring cloud...
Read more >
A Quick Guide to Spring Cloud Consul
In this article, we'll see how we can configure a Spring Boot application to use these ... Spring provides a DiscoveryClient API for...
Read more >
Quick Guide to Microservices with Spring Boot 2, Eureka ...
Discovery client will be enabled for microservice after including ... In fact, this is the example of Config First Bootstrap approach, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found