Ole*_*leg 7 java spring spring-boot
我在application.properties文件中指定了Spring属性.如何从环境变量中填充这些属性?
这是我尝试过的,但它似乎不起作用:
application.properties
spring.datasource.url=jdbc:postgresql://#{ systemProperties['DATABASE_HOST']}:5432/dbname
spring.datasource.username = postgres
spring.datasource.password = postgres
Run Code Online (Sandbox Code Playgroud)
您可以像使用${...}语法引用Spring属性一样引用环境属性.
在你的情况下:
spring.datasource.url=jdbc:postgresql://${DATABASE_HOST}:5432/dbname
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11461 次 |
| 最近记录: |