我在 application.properties 文件中指定了 Spring 属性。我如何从环境变量中填充这些属性?
这是我试过的,但似乎不起作用:
application.properties
spring.datasource.url=jdbc:postgresql://#{ systemProperties['DATABASE_HOST']}:5432/dbname
spring.datasource.username = postgres
spring.datasource.password = postgres
最佳答案
您可以像使用 ${...}
语法引用 Spring 属性一样引用环境属性。
在你的情况下:
spring.datasource.url=jdbc:postgresql://${DATABASE_HOST}:5432/dbname
关于java - spring - 从 application.properties 文件中读取环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39703453/