How to activate Profile in Spring Boot Yaml

Viewed 1233

I have below application yaml of my Spring boot(2.4.5) application with two profiles.

spring: profiles: dev


spring: profiles: prod

Now when i pass the arguments -Dspring.profiles.active=dev , it actually doesn't pickup the profile. Is there any changes in profile has been made recently.

When i active the profile , like below it works

spring: profiles: active: dev

but as per the env profile can be different . i dont want to hard code the profile

1 Answers

You should use the following instead in your application.yml:

spring
   config:
      activate:
         on-profile: dev

---
    
spring
   config:
      activate:
         on-profile: prod
Related