Read profile-specific properties programatically during runtime in Spring Boot

Viewed 20

My Spring Boot application (v2.7.1) defines three profiles with their respective property files:

  • application-local.yml
  • application-dev.yml
  • application-prod.yml

I know how to set the active profile when starting the application but does Spring also provide a way to read the profile-specific properties programatically during runtime?

The application is a shell application. When running, for example, a command like init --stage dev, then I'd like to use the properties from application-dev.yml.

0 Answers
Related