Profile doesn't work on application.properties file but on equivalent yaml file
See original GitHub issueDescribe 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:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
properties files won’t support mutltiple inline documents until boot 2.4.x