Skip to content

This is a simple Spring Boot project that implements basic CRUD (Create, Read, Update, Delete) operations for managing employee data via RESTful APIs. It serves as a foundational project to understand how Spring Boot works with REST endpoints and an MySQL database.

Notifications You must be signed in to change notification settings

COREayan/Java-Spring-Boot-Employee-REST-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

👨‍💼 Employee Management REST API

This is a Spring Boot project that implements basic CRUD(Create, Read, Update, Delete) operations for managing employee data via RESTful APIs. It serves as a foundational project to understand how Spring Boot works with REST endpoints and an MySQL database.

📌 Features

  • Create a new employee
  • Retrieve all employees
  • Retrieve an employee by ID
  • Update employee details
  • Delete an employee
  • RESTful API architecture
  • MySQL Database

Well-structured with best practices using Spring Boot annotations

🧱 Technologies Used

  • Java 17+
  • Spring Boot
  • Spring Data JPA
  • MySQL
  • Maven
  • JUnit and Mockito
  • Docker

Backend Setup

  1. Clone the repositor:
  2. Update the database configuration in application.properties
  3. Build the project:
  4. Run the application:

Flow of the Program

  1. Initally there is no table in database 'employee_directory' called 'employee'. img_1.png

  2. After running the Spring Boot Application, 'employee' table is created. img.png

3.Initially, the table is blank.

img.png

  1. Hitting the GET http://localhost:8080/api/employees API using Postman. img.png blank JSON response.

  2. Hitting the POST /api/employees API using Postman with JSON data. { "firstName": "Alice", "lastName": "Walker", "email": "[email protected]" } img.png

  3. Checking the data in MySQL Workbench. img.png 1 employee created. Why first_name and last_name columns are blank? OOPS! the column names are different in Employee POJO class, than the JSON data we provided. img_1.png

  4. Lets create another employee the same way. img_2.png 2nd employee created. Let's check in the database. img.png Now it is good.

  5. Let's create 2 more employee. img_1.png img_2.png Check in the database. img.png

  6. Check using the get all employee API using Postman. img.png

  7. Check get employee by ID API using Postman. img.png

  8. Check Put employee API using Postman. img.png database data -> img.png

  9. Lets Delete employee record 4. Before deleting -> img_1.png Postman Screenshot -> img.png After deleting -> img_1.png

API Endpoints

  1. Create Employee
  • POST /api/employees { "firstName": "Jane", "lastName": "Smith", "email": "[email protected]" }
  1. Get All Employees
  • GET /api/employees
  1. Get Employee by ID
  • GET /api/employees/1
  1. Update Employee
  • PUT /api/employees { "id": 1, "firstName": "Jane Updated", "lastName": "Smith", "email": "[email protected]" }
  1. Delete Employee
  • DELETE /api/employees/4

About

This is a simple Spring Boot project that implements basic CRUD (Create, Read, Update, Delete) operations for managing employee data via RESTful APIs. It serves as a foundational project to understand how Spring Boot works with REST endpoints and an MySQL database.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages