Reputation: 155
I have exported some simple db creds on my machine as ENV variables.
export MYSQL_USER=root
export MYSQL_PASS=pass
I'm trying to load these dynamically into my profile into spring boot, but to no avail. I'm starting to believe this is because the application runs inside a TomCat container and therefore isolated from the machine env vars.
spring.datasource.username = ${MYSQL_USER}
However, it's still being seen as literal plain text of ${MYSQL_USER}
. Does Spring Boot have the capability for readingg in system environment variables?
Upvotes: 0
Views: 2999
Reputation: 96
I was also having same problem to get OS env variables into my application.properties/yml using the $ sign. To solve this, I defined the variables to application server(tomcat/jboss etc). Then only the application.properties/yml can get them. Hope this will help.
Upvotes: 1