Search code examples
spring-bootjdbcdatasourceapplication.properties

How to bind datasource property from env variables Spring boot


How to bind datasource property from env variables Spring boot

I have some property

spring.datasource.url=
spring.datasource.username=
spring.datasource.password=

and i need to fill db connection parameters from env variable

java -jar demo-0.0.1-SNAPSHOT.jar -DdbUrl=URL -DdbUser=USER -DdbPassword=PASSWORD

how can i do this? binding like spring.datasource.url=${URL} doesnt works(


Solution

  • Try to pass your parameters like:

    --spring.datasource.url=jdbc:xx:xx:xxx
    

    Instead of -DparamName