Spring Boot MySQL Database Setup with JPA | Chapter #2

Genuine Coder
Genuine Coder
10.1 هزار بار بازدید - 2 سال پیش - In this tutorial, we will
In this tutorial, we will explore how to use the spring boot CRUD repository to easily create, retrieve, update and delete database objects. First, we will add a new database Entity model and set up an auto-incremented integer primary key for the model. In Spring JPA, you can add @Entity annotation to mark a class as a database entity. It will then be automatically taken by the Spring JPA and a database table will be created for the same.

Then, we will create a CRUD repository by extending org.springframework.data.repository.CrudRepository and use it in a DAO (Data Access Object) class. Spring boot CRUD provides many functions that can be used directly without having to write any code. For example, the save(T entity) function saves an entity model to the database, and we don't have to write any special code to do that.

After setting up the CRUD Repository and the DAO class, we will write a unit test to make sure that the repository is indeed working as expected.

You can find this project in GitHub at https://github.com/afsalashyana/Sprin...
Genuine Coder Blog: https://www.genuinecoder.com/

Tags: #Java #SpringBoot

Introduction: (0:00)
Create new Employee JPA Entity: (01:01)
Configure Spring Boot Component Scan: (05:55)
Create new CRUD Repository: (09:36)
Setting up DAO (Data Access Object): (12:02)
Test the repository: (18:13)
2 سال پیش در تاریخ 1400/12/24 منتشر شده است.
10,101 بـار بازدید شده
... بیشتر