0

I have a spring boot application. Currently, for a certain requirement, I am trying to read environment variables in application properties. This is what I have in my application.properties file:

notes.userName=${credentials.username}

In environment variables, the value for "credentials.username" is testUser. But while I run the program and try to read from notes.userName, the value is literally "${credentials.username}".

Is there anyother to set environment variables into application properties file.

NOTE: I am aware that I can read the environment variables directly but the requirement is to read the environment variabes from application properties.

Jack
  • 67
  • 1
  • 6
  • There can be many reasons why it is not reading. Which OS is it? Did you load the env files after you added the properties? Did you restart the system? Did you restart your application? – cosmos Mar 06 '19 at 20:57
  • I am using windows. I am testing it using STS/eclipse. I have set the environment variables in the run/debug configuration and have restarted the application as well as the system. – Jack Mar 06 '19 at 21:02
  • How are you reading `notes.userName`? What made you conclude that it's not reading the environment variables? – cosmos Mar 06 '19 at 21:04
  • because all the other properties that I am reading via application properties is showing fine. – Jack Mar 06 '19 at 21:09
  • Can you update on how you are reading the properties and what you are getting for `notes.userName`? – cosmos Mar 06 '19 at 21:11
  • I am using @ value annotation – Jack Mar 06 '19 at 21:28
  • You need to read up https://stackoverflow.com/help/mcve before anyone can answer your question. – cosmos Mar 06 '19 at 21:32

0 Answers0