【问题标题】:How to bind datasource property from env variables Spring boot如何从环境变量绑定数据源属性 Spring boot
【发布时间】:2018-05-31 09:15:32
【问题描述】:

如何从环境变量 Spring boot 绑定数据源属性

我有一些财产

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

我需要从环境变量中填充数据库连接参数

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

我该怎么做? 绑定like spring.datasource.url=${URL} 不起作用(

【问题讨论】:

    标签: spring-boot jdbc datasource application.properties


    【解决方案1】:

    尝试传递您的参数,例如:

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

    而不是 -DparamName

    【讨论】:

    • 它有效!但是现在我在构建应用程序时需要在数据源自动配置期间跳过测试
    猜你喜欢
    • 2021-02-09
    • 2017-02-12
    • 2022-01-12
    • 2020-06-19
    • 2018-04-12
    • 1970-01-01
    • 2019-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多