Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

In our config server we have following application properties files:

helloApp-dev.properties //dev env properties
helloApp-commonConfig.properties //common properties across env

The properties are accessible from URI like:

https://myapp.abc.com/1234/helloApp-dev.properties
https://myapp.abc.com/1234/helloApp-commonConfig.properties

Below is our bootstrap.yml of helloApp application:

---
spring:
  application:
    name: helloApp
    
---
spring  
  profiles: dev
  cloud:
    config:
      label: 1234
      name: {spring.application.name}
      uri: https://myapp.abc.com/

I am using Spring boot version 2.2.4. The helloApp-dev.properties are loading successfully in application but not commonConfig.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

To load properties file, profiles should match. You have 2 solutions:

  1. Rename helloApp-commonConfig.properties -> helloApp.properties
  2. Use multiple profiles for your application (dev, commonConfig)
over 4 years ago · Santiago Trujillo Report

0

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:

---
spring  
  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 helloApp-dev.properties you need to include the following information within the rest of your configuration:

spring.profiles.include=commonConfig

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

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!