gpt4 book ai didi

postgresql - Gradle项目中如何连接PostgreSQL

转载 作者:行者123 更新时间:2023-12-03 05:21:44 25 4
gpt4 key购买 nike

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

最佳答案

添加 PostgreSQL依赖于 build.gradle

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,..在你的代码中。

关于postgresql - Gradle项目中如何连接PostgreSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63222401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com