<p>I have to pass env variables in JAVA SpringBoot Application.</p>
<p>I have created k8s secrets. I am passing them in k8s deployment YAML as env variables USER_NAME and USER_PWD.</p>
<p>But How to read these env variables in the application.properties file.
I have tried ${USER_NAME} but it's not working.</p>
<p>Ex. from application.properties file.</p>
<p><code>spring.datasource.username=${USER_NAME}</code></p>

avadhut007
<p>Thank you, It is solved now.</p>
<p>I needed to pass the variables while running the JAR as well.</p>
<p>Ex. from application.properties file.</p>
<p><code>spring.datasource.username=${USER_NAME}</code></p>
<p>and in Dockerfile</p>
<p><code>ENTRYPOINT exec java -DUSER_NAME=$USER_NAME -DUSER_PWD=$USER_PWD -jar jar-name.jar</code></p>
