Tutorial about CRUD operations in Spring Boot with Spring Data JPA. Application developed in this tutorial performs adding, editing, updating and deleting contacts.
We will be using the following to successfully create our application in this tutorial:
- Spring Web (Spring MVC, Spring Web MVC, a lot)
- Spring Data JPA (JPA, Hibernate)
- Thymeleaf - template engine; bye JSP!
- Many more, more than 50. With just a few lines in our pom.xml, let Spring Boot provide everything.
Create A Project
Go to Spring Initializr and create a Maven project.
Once done, hit Generate Project button to save the project.
Unzip the project and start coding. You can use any editor or IDE you prefer. For Eclipse users, you will have to issue the following command via Terminal before importing to Eclipse:
$ cd springbootcrud
$ mvn eclipse:eclipse
For NetBeans users, just click File > Open Project... or click Open Project toolbar, and locate where you unzipped the project. NetBeans natively suports Maven project, no conversion needed.
Updadte your pom.xml:
Create database in MySQL. Mine is springbootcrud. Add the following table:
Insert the following to application.properties
Running the Application
$ mvn package && java -jar target/springbootcrud-0.0.1.jar
Open your browser and point to: http://localhost:8080
Contact List (without records)
Add Contact Form
Contact List (with records)
Edit Contact Form
Please post your comments or suggestions.
You can download complete source code here.