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
  • 115,695
  • 22
  • 220
  • 224
Sritam Jagadev
  • 955
  • 4
  • 18
  • 46

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"