https://github.com/prathampalsingh/springboot_curd_operations
This project demonstrates fundamental concepts of Java, Spring, and MySQL by creating a simple application that interacts with a relational database.
https://github.com/prathampalsingh/springboot_curd_operations
jakarta java-8 lombok mysql-driver spring-boot spring-data-jpa spring-web
Last synced: 3 months ago
JSON representation
This project demonstrates fundamental concepts of Java, Spring, and MySQL by creating a simple application that interacts with a relational database.
- Host: GitHub
- URL: https://github.com/prathampalsingh/springboot_curd_operations
- Owner: prathampalsingh
- Created: 2025-01-10T18:09:12.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-01-18T11:40:30.000Z (5 months ago)
- Last Synced: 2025-03-14T01:12:36.057Z (3 months ago)
- Topics: jakarta, java-8, lombok, mysql-driver, spring-boot, spring-data-jpa, spring-web
- Homepage:
- Size: 51.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spring Boot CRUD Operations with MySQL
This project demonstrates fundamental concepts of Java, Spring Boot, and MySQL by creating a simple application that interacts with a relational database.
**Key Features:**
* **Spring Boot:** Leverages the Spring Boot framework for rapid application development, including dependency injection, auto-configuration, and embedded servers.
* **MySQL:** Utilizes MySQL as the underlying database for data storage and retrieval.
* **JPA and Hibernate:** Employs Java Persistence API (JPA) and Hibernate as the Object-Relational Mapping (ORM) layer to interact with the database using Java objects.
* **CRUD Operations:** Implements core CRUD (Create, Read, Update, Delete) operations on a chosen entity (e.g., a User, Product) through a RESTful API.
* **RESTful API:** Exposes endpoints (e.g., GET, POST, PUT, DELETE) for interacting with the data using HTTP requests.**Technical Steps:**
1. **Project Setup:**
* Create a Spring Boot project using Spring Initializr.
* Use Java version 17 or higher and Maven.
* Add dependencies for:
* Spring Web
* Spring Data JPA
* MySQL Driver
* Lombok2. **Project Setup (After Cloning):**
* Run `mvn clean install` in the terminal to download all dependencies.
3. **Database Setup:**
* Create a database named `newdb` using the following SQL command:
```sql
create database newdb abcd;
```* Important: Update the `username` and `password` in the `application.properties` file with your MySQL credentials.
4. **Run the Application:**
* Start the Spring Boot application using your preferred IDE or by running `mvn spring-boot:run` in the terminal.
5. **Explore and Experiment:**
* Use a tool like Postman to interact with the exposed RESTful endpoints.
* Test the CRUD operations using Postman.
* Modify the entity, service, and controller classes to explore different functionalities.**Getting Started with Postman:**
1. Install Postman: https://www.getpostman.com/
2. Create a new collection for your project.
3. **Create Operation:**
* Set the request method to `POST`.
* Set the URL to `http://localhost:8080/addStd` (assuming the application runs on port 8080).
* In the Body tab, select `raw` and set the content type to `application/json`.
* Provide a JSON object representing the student data you want to create
```json
{"name": "John Doe","mark": 30}
```
* Send the request.
5. **Read Operation:**
* Set the request method to `GET`.
* Set the URL to `http://localhost:8080/getAllData` to retrieve all students.
* You can also use `http://localhost:8080/getStdById/{id}` to retrieve a specific student by ID, replacing `{id}` with the actual student ID.
* Send the request.
6. **Update Operation:**
* Set the request method to `PUT`.
* Set the URL to `http://localhost:8080/updStd`.
* In the Body tab, provide a JSON object representing the updated student data.
* Send the request.
7. **Delete Operation:** (**Not implemented in this example project**):
* You can implement a DELETE endpoint to remove students from the database. Refer to Spring Data JPA documentation for guidance.This project provides a solid foundation for understanding core Spring Boot concepts and building more complex applications with database interactions.
**Result**Student database:

Spring Starting:

Post student data in database using postman:

Get Student data by ID in postman:

**Note:*** This README file provides a basic overview. For detailed instructions and implementation specifics, refer to the project's source code and comments.
* This project is intended for educational and learning purposes.**I hope this enhanced README file is more informative and appealing!**