VOOZH about

URL: https://www.geeksforgeeks.org/springboot/employee-management-system-using-spring-boot/

⇱ Employee Management System Project using Spring Boot - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Employee Management System Project using Spring Boot

Last Updated : 8 Oct, 2025

The Employee Management System (EMS) is a Spring Boot web application that manages employee records. It allows adding, updating, deleting individual employees, viewing all employees in a table, and deleting all records after confirmation.

Project contains complete EMS application, including database setup, model, repository, controller and front-end integration with Thymeleaf and Bootstrap.

Prerequisites

To follow this tutorial, basic knowledge of the following is required:

  • Spring Boot and Spring MVC
  • Thymeleaf for dynamic HTML rendering
  • MongoDB for data storage
  • Bootstrap for responsive UI

Employee Data Fields

Each employee record contains:

  • Employee ID (auto-generated)
  • Employee Name
  • Employee Email
  • Employee Phone Number
  • Employee Gender
  • Employee Salary
  • Employee Role

Project Setup

Dependencies (build.gradle)

Project Structure:

πŸ‘ project-structure

Database Configuration

spring.data.mongodb.host=localhost

spring.data.mongodb.port=27017

spring.data.mongodb.database=ems


spring.thymeleaf.prefix=classpath:/templates/

spring.thymeleaf.suffix=.html

Model Layer

Employee.java

Annotations:

  • @Data: generates getters, setters, equals, hashCode, and toString
  • @AllArgsConstructor: parameterized constructor
  • @NoArgsConstructor: default constructor
  • @Document: maps class to MongoDB collection

ConfirmationForm.java

Used for confirming deletion of all employees

Repository Layer

EmployeeRepo.java:

The repository extends MongoRepository providing CRUD operations for Employee.

Controller Layer

EmployeeController.java: handles HTTP requests and integrates the repository with Thymeleaf views:

View Layer (index.html)

The index.html file uses Thymeleaf and Bootstrap to render employee data and forms for CRUD operations. The page includes:

  • Table to display all employees
  • Modal forms to add, update, delete single employee
  • Modal form to delete all employees after typing β€œYes”

Adding Employee Modal

Output screen of Index Page:

πŸ‘ Index Page for Employee Management System

Insert Employee Data

For Inserting Employee data into database I used EmployeeRepo object which provides save() methods which is used for saving employee data into database.

Output screen of Insert Employee:

πŸ‘ Insert Employee in Database

Update Employee Data

If you want to update an employee, you need existing employee ID then we can update employee data other wise not possible. It is a same Inserting data but Before inserting in this method I check if employee id exist or not. If exist I give access to update employee information.

Output screen of Update Employee Details:

πŸ‘ Updating Employee Information in System

Delete Employee Data

For Deleting an Employee, we need Employee ID, then only we can be able to delete an existing employee otherwise it's not possible to delete. After Successful delete, the result is updated in Employee table for this I used Thymeleaf for handling the Employee pojo class.

Output screen of Delete Employee:

πŸ‘ Delete Employee from the Database

Delete All Employees

The Delete All employee's logic is working based on user confirmation. The Confirmation is nothing but while before deleting all data the application asks your confirmation, if you type yes in the given text field means your confirmed to delete all employee's data.

Output Screen of Delete all Employees:

πŸ‘ Delete All Employee Details
πŸ‘ After Deleting All Employees
Comment

Explore