Learn how to connect a Spring Boot REST API to PostgreSQL using Spring Data JPA and Hibernate.
In this hands-on Spring Boot tutorial, we'll take the REST API we built in the previous video and replace the in-memory List with a real PostgreSQL database.
You'll learn how Spring Data JPA, Hibernate, JPA Entities, Repositories, DTOs and PostgreSQL work together to create a database-backed REST API.
By the end of this tutorial, your Spring Boot application will be able to persist user data in PostgreSQL — even after restarting the application.
🚀 WHAT YOU'LL LEARN
✅ Connect Spring Boot to PostgreSQL
✅ Configure PostgreSQL database connection
✅ Add Spring Data JPA
✅ Understand JPA and Hibernate
✅ Create a JPA Entity
✅ Use @Entity, @Id and @GeneratedValue
✅ Create a JpaRepository
✅ Replace in-memory List persistence
✅ Map Entity ↔ DTO
✅ Implement CRUD operations with PostgreSQL
✅ Test REST APIs using Postman
✅ Understand INSERT vs UPDATE with JPA
✅ Verify data persistence after application restart
Timeline:
00:00 - Problem Statment
01:53 - Previous & new architecture with DB
02:45 - PostgreSql DB introduction
04:08 - Added dependencies for Spring data JPA and PostgreSql
06:43 - Update application properties file
09:30 - Create User Model
12:21 - Table created using JPA (Hibernate)
13:20 - Create UserRepository
16:01 - UserMapper class for mapping UserDto to User model and vice-versa
19:10 - Update UserService for UserRepository
20:37 - Amend GET users api
22:03 - Amend GET users by id api
23:10 - Amend POST users api
24:53 - Amend PUT users api
28:04 - Amend DELETE users api
28:53 - Test API using postman
33:16 - Assignment & Next Requirement
🛠️ TECHNOLOGIES USED
• Java
• Spring Boot
• Spring Data JPA
• Hibernate
• PostgreSQL
• Maven
• REST API
• Postman
📌 IMPORTANT
In the previous video, we created a complete CRUD REST API using an in-memory Java List.
In this video, we're taking the next step and replacing that temporary storage with PostgreSQL so that our data remains available even after restarting the Spring Boot application.
This is part of the Slash Code Spring Boot Backend Development series, where we're building a REST API step by step and gradually turning it into a production-style backend application.
📺 PREVIOUS VIDEO
Build a REST API with Spring Boot from Scratch | Complete CRUD Tutorial - • Build a REST API with Spring Boot from Scr...
▶️ Watch the previous video and follow the project from the beginning.
🎯 ASSIGNMENT
Add a new field such as phoneNumber to the User Entity and UserDto.
Update the API and database mapping, then test creating and updating users using Postman.
💡 NEXT VIDEO
Spring Boot REST API Validation with @Valid
We'll learn how to validate incoming API requests and prevent invalid data from entering our application.
If you're learning Java, Spring Boot and backend development, subscribe to Slash Code for practical, real-world software engineering tutorials.
#SpringBoot #PostgreSQL #SpringDataJPA
On this page of the site you can watch the video online Connect Spring Boot REST API to PostgreSQL | Spring Data JPA Tutorial with a duration of hours minute second in good quality, which was uploaded by the user Slash Code 19 August 2026, share the link with friends and acquaintances, this video has already been watched 52 times on youtube and it was liked by 4 viewers. Enjoy your viewing!