-1

I have this in my Java code.If fieldOne is not present in properties file 1)In prod environment(application_prod.yml) --fieldOne value should be true 2)For all other environment (application_uat.yml/application_int.yml)--fieldOne value should be false.

How to achieve it?

@Value("${fieldOne:true}")
 private String fieldOne;
Pale Dot
  • 17
  • 4
  • Does this answer your question? [How do you get current active/default Environment profile programmatically in Spring?](https://stackoverflow.com/questions/9267799/how-do-you-get-current-active-default-environment-profile-programmatically-in-sp) – Abhijit Sarkar Mar 22 '22 at 06:01

1 Answers1

0

You can use application.yml to provide a default value that's overridden by profile specific files.

The order in which spring evaluates external configuration is documented here.

Hopey One
  • 1,681
  • 5
  • 10