How to connect PostgreSQL in Gradle Project

11,622

Add PostgreSQL dependency in build.gradle

runtimeOnly 'org.postgresql:postgresql'

then, add the properties in 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

then, Implement you JPA, jdbctemplate,.. in your code.

Share:
11,622
rajen var
Author by

rajen var

Updated on June 04, 2022

Comments

  • rajen var
    rajen var almost 2 years

    I am trying to connect PostgreSQL in gradle project. I have a requirement to make CRUD operations. CAN SOME HELP ME. Thanks in Advance

    • Suraj Muraleedharan
      Suraj Muraleedharan almost 4 years
      The question is too vague. Please do raise the questions after you do your own research and nothing works out. Also indicate what you have been tried and at which step you failed. We are sure that there are lots of tutorials out there to setup postgres.