Skip to content

A simple Client CRUD application built with Spring Boot, providing RESTful APIs for managing client data, including create, read, update, and delete operations.

Notifications You must be signed in to change notification settings

MaarceloLuiz/springboot-crud-apirest-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clients CRUD - Spring Boot

Objective

Develop a RESTful API with full CRUD operations for managing clients.

Features

  • Paginated client list
  • Search clients by ID
  • Add new clients
  • Update existing clients
  • Delete clients
  • Exception handling for:
    • Resource not found (404)
    • Validation errors (422)

Domain Model

  • Client: Contains fields for id, name, CPF, income, birthDate, and children.

image

Tech && Frameworks

  • Spring Boot: Framework for building the REST API.
  • JPA/Hibernate: ORM for database management.
  • H2 Database: In-memory database for testing.
  • Postman: For testing the API endpoints.
  • Maven: Build automation.

How to Run

Prerequisites

  • Java 8 or higher
  • Maven

Steps

1. Clone the repository:

git clone https://github.com/MaarceloLuiz/springboot-crud-apirest-client.git
cd springboot-crud-apirest-client

2. Build the project using Maven and run the Application:

mvn clean install
mvn spring-boot:run

3. Open Postman (or any API testing tool).

4. Use the following base URL to access the API endpoints:

http://localhost:8080

5. The available endpoints include:

  • GET /clients - Retrieve a paginated list of clients.
    • You can use query parameters such as page, size, and sort to control the pagination:
    • page: Page number (starting from 0).
    • size: Number of results per page.
    • sort: Sorting field (e.g., name).
  • For example: to retrieve the second page of clients with 10 results per page, sorted by name:
http://localhost:8080/clients?page=1&size=10&sort=name
  • GET /clients/{id} - Retrieve client details by ID.
  • POST /clients - Add a new client (requires a JSON body).
  • PUT /clients/{id} - Update an existing client by ID.
  • DELETE /clients/{id} - Delete a client by ID.

For example, you can test the GET /clients endpoint in Postman by sending a request to:

http://localhost:8080/clients

6. To stop the application run the following command in the terminal:

mvn spring-boot:stop

Author

Marcelo Luiz Guimarães Pereira

LinkedIn


About

A simple Client CRUD application built with Spring Boot, providing RESTful APIs for managing client data, including create, read, update, and delete operations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages