A simple REST API built with Spring Boot that allows you to manage users. The API provides endpoints to create, read, update, and delete user information.
- 🧑💻 Get All Users: Retrieve a list of all users.
- 🔍 Get User by ID: Fetch details of a specific user by their ID.
- ➕ Create a New User: Add a new user to the database.
- ♻️ Update an Existing User: Modify details of an existing user.
- ❌ Delete a User by ID: Remove a user from the database.
- Java: Programming language.
- Spring Boot: Framework for building RESTful web services.
- Maven: Dependency management.
- Java 17 or later
- Maven 3.8.x or later
-
Clone the repository:
git clone https://github.com/your-username/spring-boot-crud-api.git cd spring-boot-crud-api
-
Build the project with Maven:
mvn clean install
-
Run the application:
mvn spring-boot:run
The application will start and run on
http://localhost:4000
.
-
GET
/user
Retrieves a list of all users.
curl -X GET http://localhost:4000/user
-
GET
/user/{id}
Fetches the details of a user by their ID.
curl -X GET http://localhost:4000/user/1
-
POST
/user
Adds a new user to the database.
curl -X POST http://localhost:4000/user -H "Content-Type: application/json" -d '{"firstName": "John", "lastName": "Doe", "email": "[email protected]"}'
-
PUT
/user/{id}
Updates details of an existing user.
curl -X PUT http://localhost:4000/user/1 -H "Content-Type: application/json" -d '{"firstName": "John", "lastName": "Doe", "email": "[email protected]"}'
-
DELETE
/user/{id}
Removes a user from the database by their ID.
curl -X DELETE http://localhost:4000/user/1
Contributions are welcome! Feel free to fork the repository and open a pull request.