Develop a RESTful API with full CRUD operations for managing clients.
- 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)
- Client: Contains fields for
id
,name
,CPF
,income
,birthDate
, andchildren
.
- 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.
- Java 8 or higher
- Maven
git clone https://github.com/MaarceloLuiz/springboot-crud-apirest-client.git
cd springboot-crud-apirest-client
mvn clean install
mvn spring-boot:run
http://localhost:8080
- 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.
http://localhost:8080/clients
mvn spring-boot:stop
Marcelo Luiz Guimarães Pereira