Bootstrap.Yml Not Loading in Spring Boot 2

bootstrap.yml not loading for Spring Boot 2

The bootstrap.yml (or .properties) file is only used, if you use any of the Spring Cloud Starter modules. This is used to specify the spring cloud config server location for bootstrapping a minimal application context that will gather the application properties from the config server and then create a child context with these properties to start the real application.
If you do not make use of the Spring Cloud config capabilities, the way to go is to use the application.yml or .properties files for your application.

Spring boot is not loading file

I took a look at your pom file, you are not creating any springboot cloud project because typically you will find a corresponding Spring Cloud BOM version in pom.xml if you used, like so


That's why the bootstrap file is being dismissed.
Here is a number of spring cloud projects you can use.

You can start by:

A. creating a spring cloud config server project

B. Make your actual project the spring cloud config client
here is the official tutorial

Sorry If I'm not understanding your question properly, but if you are already created a springcloud project, one possible issue is the version...

Here similar issue was raised on Stack Overflow.

bootstrap.yml configuration not processed anymore with Spring Cloud 2020.0

As pointed put by Nicoll, With Spring Cloud Vault 3.0 and Spring Boot 2.4, the bootstrap context initialization (bootstrap.yml, of property sources was deprecated. This can be fixed in one of the 2 ways

  1. Use Spring Boot 2.4.0 Config Data API to import configuration from Vault (Preferred)
  2. Legacy Processing: Enable the bootstrap context either by setting the configuration property or by including the dependency

1. Use Spring Boot 2.4.0 Config Data API (Preferred)

Move bootstrap.yml configuration to application.yml and updated file looks like below


authentication: APPROLE
role-id: ${role-id}
secret-id: ${secret-id}
role: pres-read
app-role-path: approle
uri: ${vault-server}
connection-timeout: 5000
read-timeout: 15000
import: vault://secret/app/pres/

And define individual profiles as shown below. Add spring.config.import: vault://secret/app/pres/demo property.


## Server Properties
port: 8081

import: vault://secret/app/pres/demo
username: ${pres.db.username}
password: ${pres.db.password}
url: ${pres.db.url}
driver-class-name: com.mysql.cj.jdbc.Driver

Repeat the same process for all profiles like dev, test, qc, staging and prod.

2. Legacy Processing:

Add the following dependency if you still want to use bootstrap.yml


to the project. The issue will be resolved.

See Spring Cloud Vault docs for more information

Config Client is not working in Spring boot

2020.0.0 Spring Cloud Config does not support bootstrap file.

For a workaround use bootstrap.{yml|properties} and add a dependency on
spring-cloud-starter-bootstrap to restore the old behavior.


More information:

Spring Boot: Load common config application properties file using bootstrap.yml

The configuration in commonConfig is not being loaded because you are not indicating to Spring that it should load that profile/config, because you are activating only the dev profile - and the configuration for that profile is the one which is being loaded:

profiles: dev

In addition to the good solutions proposed by @akozintsov in his/her answer, if you need to include certain common configuration in different environments or profiles, let's say dev, qa or prod, you can use the spring.profiles.include configuration property and include, as a comma separated list of values, if using properties files, or as a list, if using yaml, the different common profiles and corresponding configurations you need to.

In your example, in you need to include the following information within the rest of your configuration:


These related SO question and this article could be of help as well.

Why is ignored by spring-cloud-starter-config?

With Spring Cloud 2020, they made a change in how bootstrap works and you have to include a new starter: spring-cloud-starter-bootstrap.

Related Topics

Leave a reply