Watch This Youtube Video to Understand the Code, Click Here
Here in this article, I'm going to create a Simple CRUD based Web project using Spring Boot, Thymeleaf, Spring Data JPA, Lombok, Maven with MySql Database.
In this project I'm creating an user, updating the user and deleting the user. This article is very useful for who are start creating web pages using Spring boot.
Home Page
Home Page |
Adding New User Page
Adding an User Page |
Updating New User Page
Updating an User Page |
Steps to create the project.
- Open Spring Initializer and fill the details of your project like Maven version , java version, Project name etc. as shown below and add the the required depenedencies.
- Lombok
- Thymeleaf
- MySql Driver
- Spring Data Jpa
- Spring Web
- Import the project in your IDE, i'm using intellij IDE.
- When import is successfull, you can see the project in left side of the panel.
- Expand the Project and packages and add all the classes and Html files and in configure the properties in application.properties files.
- Configure the application by adding below configuration on application.properties file
spring.datasource.url = jdbc:mysql://localhost:3306/database_namespring.datasource.username = rootspring.datasource.password = rootspring.datasource.driver-class-name = com.mysql.cj.jdbc.Driverspring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialectspring.jpa.hibernate.ddl-auto = updatespring.jpa.show-sql = true
- Now Create the following classes and HTML files in respective packages as shown in above picture. In this project I'm not create the service class because in this project there is no need of any service class, if you want to add you can add.