我的 Spring Boot 项目使用 application.yml 作为配置,我不想在其中写入数据库凭据,因为 yml 文件是源代码的一部分,它将被推送到公共代码存储库中。因此,我需要将凭据放入属性文件中,并将属性文件放在应用程序主机服务器上的某个位置。
那么,是否可以将 application.yml 中的表达式外部化到属性文件中?
例如带有 application.yml 的 sprint 启动应用程序
spring:
datasource:
jdbc-url: ${url}
username: ${user}
password: ${pwd}
然后我们可以将凭据放入 app.properties 中,如下所示,并将该文件放入主机服务器中。
url="jdbc:xxxx"
user="username"
pwd="password"
holdtom
茅侃侃
相关分类