Spring boot (confg client) application doesn't pick bootstrap.yml

See original GitHub issue

I’m creating a spring boot config client application. I’ve been referring to various online material - I’ve already referred to most of it. Im using STS. The application simply doesn’t pick up the bootstrap.yml at all. I should see the config from bootstrap file being loaded here - http://localhost:8080/env. I see entries only from application.yml, but not bootstrap. I verified my Config server is running (http://localhost:8888/trial1client/default/master) using correct GIT. Following is my POM

<?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.trial</groupId>
	<artifactId>trial1client</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>
	<name>trial1client</name>
	<description>Trial1 client</description>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.7.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>Dalston.SR3</spring-cloud.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-config</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<dependencyManagement>
		<dependencies>
			<dependency>
	            <groupId>io.pivotal.spring.cloud</groupId>
	            <artifactId>spring-cloud-services-dependencies</artifactId>
	            <version>1.5.0.RELEASE</version>
	            <type>pom</type>
	            <scope>import</scope>
	        </dependency>
			<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 6 years ago
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
msathe-techcommented, Sep 27, 2017

Well, here is the solution, that worked for me -

  1. Add following to POM <dependencyManagement> <dependencies> <dependency><groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Camden.SR5</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>

Don’t ask why, just do it because it worked 😃 2. Remove following from POM - <spring-cloud.version>Dalston.SR3</spring-cloud.version> from <properties> Something similar to that in in <properties> Don’t ask why, just do it because it worked 😃 3. If you are using local file system for GIT then make sure you add ‘/.git/’ to the path e.g. spring.cloud.config.server.git.uri=C:/stswork/workspace-sts-3.9.0.RELEASE/trial1/src/main/resources/.git/ Sadly, none of the docs suggest to add ‘.git’ in the path URI.

What you need to check out for -

  1. Make sure none of your annotations show any warning sign in your IDE, that tiny ‘!’ causes trouble
  2. Config server logs - check for message similar to following, to check client specific config file you have created - NativeEnvironmentRepository : Adding property source: file:/C:/…/trial1client.properties
  3. Config client logs - check for something similar to following indicating client is able to pull the config

c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888 2017-09-27 15:46:42.443 INFO 9696 — [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=trial1client, profiles=[default], label=master, version=232a66a62c89105653c00167de79784c44f55844, state=null 2017-09-27 15:46:42.443 INFO 9696 — [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name=‘configService’, propertySources=[MapPropertySource {name=‘configClient’}, MapPropertySource {name=‘C:/stswork/workspace-sts-3.9.0.RELEASE/trial1/src/main/resources/.git/trial1client.properties’}]]

0reactions
Nataraj2609commented, Feb 6, 2021

The Solution is to add bootstrap dependency in pom.xml

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bootstrap</artifactId>
    </dependency>

With Spring Cloud 2020, they made a change in how bootstrap works and you have to include a new starter: spring-cloud-starter-bootstrap. Refer https://stackoverflow.com/questions/65063402/why-bootstrap-properties-is-ignored-by-spring-cloud-starter-config

Read more comments on GitHub >

github_iconTop Results From Across the Web

bootstrap.yml not loading in Spring Boot 2 - Stack Overflow
I'm experiencing a problem when starting a spring boot client application that needs to connect to the configuration server. The bootstrap.yml file is...
Read more >
7. Spring Cloud Config Client
The net result of this behavior is that all client applications that want to consume the Config Server need a bootstrap.yml (or an...
Read more >
Spring Cloud - Bootstrapping - Baeldung
This article shows how to bootstrap spring cloud application by employing four common microservices, the config, the discovery, ...
Read more >
Spring Cloud - Application Context Services - bush
yml]" (and friends if Spring profiles are active). If you have a bootstrap.yml (or properties) then those properties are used to configure the...
Read more >
Bootstrapping — Spring Cloud Config Server - Medium
Assuming you have a Spring boot 2.0 app ready to bootstrap, let's add the following dependencies. I would name this app as client-config-first....
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