【问题标题】:How to connect PostgreSQL in Gradle Project如何在 Gradle 项目中连接 PostgreSQL
【发布时间】:2020-11-23 02:30:53
【问题描述】:

我正在尝试在 gradle 项目中连接 PostgreSQL。我需要进行 CRUD 操作。可以帮助我。 提前致谢

【问题讨论】:

  • 这个问题太模糊了。请在您进行自己的研究后提出问题,但没有任何结果。还要说明你已经尝试过什么以及你在哪一步失败了。我们确信有很多教程可以设置 postgres。

标签: postgresql spring-boot gradle database-connection microservices


【解决方案1】:

build.gradle中添加PostgreSQL依赖

runtimeOnly 'org.postgresql:postgresql'

然后,在application.properties中添加属性

spring.datasource.url= jdbc:postgresql://localhost:5432/sample
spring.datasource.jdbc-url=${spring.datasource.url}
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.platform=postgres
spring.datasource.username=postgres
spring.datasource.password=password

然后,在您的代码中实现 JPA, jdbctemplate,..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-26
    • 2014-10-06
    • 1970-01-01
    • 1970-01-01
    • 2011-07-11
    • 1970-01-01
    • 2021-09-06
    • 2015-11-30
    相关资源
    最近更新 更多