3

I need my application should pick value of a key from environment variables instead of application.yml.

  1. If a particular property is available in both environment variables as well as in appliation.yml then it should pick the value which is specified as part of environment variables.

  2. If a particular property is not there in environment variables then it should pick value from application.yml else not.

M. Deinum
  • 104,041
  • 21
  • 200
  • 207
Sritam Jagadev
  • 931
  • 3
  • 16
  • 39

1 Answers1

-1

For your two questions. You can use something like:

spring:
  profiles: ${YOUR_ENV_FOR_PROFILE:YOUR_DEFAULT_PROFILE}

If you set an environment variable(Ex. YOUR_ENV_FOR_PROFILE) then spring use it, otherwise spring use a default value "YOUR_DEFAULT_PROFILE"