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.

Profile doesn't work on application.properties file but on equivalent yaml file

See original GitHub issue

Describe the bug I have a configmap with a application.properties file which has some custom values. It also makes use of different profiles. However, the value in the active profile is not read by the application. Switching to equivalent application.yml file works.

Sample The original configmap with application.properties is as follows (truncated for brevity):

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  application.properties: |-
    ....
    ---
    spring.profiles: staging
    verification.url.format: https://api.dev.url.com/verification?email=%s&token=%s
    ---
    spring.profiles: prod
    verification.url.format: https://api.url.com/verification?email=%s&token=%s

When I try to read verification.url.format in the staging profile, it gives me the string in prod profile. However, switching to the following configmap works:

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  application.yml: |-
    ....
    ---
    spring:
      profiles: staging
    verification:
      url:
        format: https://api.dev.url.com/verification?email=%s&token=%s
    ---
    spring:
      profiles: prod
    verification:
      url:
        format: https://api.url.com/verification?email=%s&token=%s

Environment:

  • Spring Boot 2.3.1.REALEASE
  • Spring Cloud Kubernetes: 1.1.4.RELEASE

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
spencergibbcommented, Jul 30, 2020

properties files won’t support mutltiple inline documents until boot 2.4.x

0reactions
l0rem1psumcommented, Jul 30, 2020
  • Spring Boot 2.3.1.REALEASE
  • Spring Cloud Kubernetes: 1.1.4.RELEASE
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using application.yml vs application.properties in Spring Boot
Spring Boot supports both .properties and YAML. We explore the differences between injecting properties, and how to provide multiple ...
Read more >
Config file processing in Spring Boot 2.4
The two main problems that we have with the code are to do with profile specific documents (mainly in YAML). Namely: You can...
Read more >
Spring Boot does not correctly load profiles from application.yml
My current workaround is to set spring.profiles.active=my_profile in application.properties but I was wondering, why is spring behaving that way ...
Read more >
One-Stop Guide to Profiles with Spring Boot - Reflectoring
Profiles are a mighty tool for configuring Spring and Spring Boot applications. In this article, we discuss how Profiles work, for which use ......
Read more >
Why should we prefer the YAML file over the properties file for ...
In my opinion, the main advantages of YAML files over properties file in Spring Boot projects are the Hierarchical Structure and Popularity ...
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