我有一个 Spring Boot 应用程序,它连接到 Postgres 数据库。我在 application.properties 中将数据源 url 指定为 -
spring.datasource.url=jdbc:postgresql://<服务器ip>:5432/mydb
jdbc url (jdbc:postgresql://< server ip here >:5432/) 实际上存储在我的应用程序能够读取的单独的外部位置。因此,我只想在我的属性文件中指定数据库名称。
我不想将数据库名称作为某个环境变量传递,因为它不会改变。
我现在在这一点上停留了很长一段时间,我怎样才能达到同样的效果?
最佳答案
将此添加到您的 application.properties 文件中
spring.jpa.hibernate.ddl-auto=create\update\none
spring.datasource.url=jdbc:postgresql://host:port/db
spring.datasource.username=username
spring.datasource.password=password
关于spring - 如何在 Spring Boot 配置中显式传递数据库名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50673762/