Spring Boot + JPA + PostgreSQL

Configure Spring Boot App to work with PostgreSQL is easy.

Step 0 — Make sure you have JPA in your pom.xml

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> </dependency>

Step 1 — Add PostgreSQL into your pom.xml

<!-- PostgreSQL -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>

Step 2 — Configure your application.yaml

spring:
datasource:
url: jdbc:postgresql://localhost:5432/my-awesome-app
username: my-postgres-username
password: my-postgres-password
jpa:
hibernate:
ddl-auto: update

That’s it! Easy?