Author

Author- Ram Ranjeet Kumar
Showing posts with label CRUD application. Show all posts
Showing posts with label CRUD application. Show all posts

Saturday, February 18, 2023

Spring Boot Thymeleaf HTML CRUD example


 


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
Watch This Youtube Video to Understand the Code, Click Here

Adding New User Page

Adding an User Page
Watch This Youtube Video to Understand the Code, Click Here


Updating New User Page

Updating an User Page


Steps to create the project.
  1. 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

    •  
  2. Import the project in your IDE, i'm using intellij IDE.
  3. When import is successfull, you can see the project in left side of the panel.
  4. 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_name
spring.datasource.username = root
spring.datasource.password = root
spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = update
spring.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.