This example shows a simple REST-API with intern H2 Database access running with Quarkus.
- Quarkus
- Hibernate
- H2 Database
- Java 8
- PersonEndpoint - Responsible to receive all requests and provides all responses in JSON Format
- PersonResource- Responsible to make all database operations
- Person - Represents the model entity Person with your attributes.
- PersonsEndpointTest - Tests for some endpoints
- application.properties - all database configurations
Run ./mvnw clean package
or mvnw.cmd clean package
(Windows) to build this project.
java -jar target/restCRUDQuarkus-0.0.1-SNAPSHOT-runner.jar
- Open your postman application in localhost:8080/api/persons
- METHOD: POST
- BODY: raw - type JSON
{
"name":"NAME",
"email": "NAME@gmail.com",
"actived": false
}
- RETURN
{
"id": 1,
"name": "NAME",
"email": "NAME@gmail.com",
"actived": false
}
- Open your postman application in localhost:8080/api/persons/{id}
- METHOD:PUT
- BODY: raw - type JSON
- ID: 1
{
"name":"NAME",
"email": "NAME@gmail.com",
"actived": true
}
- RETURN
{
"id": 1,
"name": "NAME",
"email": "NAME@gmail.com",
"actived": true
}
- Open your postman application in localhost:8080/api/persons/
- METHOD:GET
- BODY: EMPTY
- RETURN
[
{
"id": 1,
"name": "NAME",
"email": "NAME@gmail.com",
"actived": true
},
{
"id": 2,
"name": "NAME2",
"email": "NAME2@gmail.com",
"actived": false
},
{
"id": 3,
"name": "NAME3",
"email": "NAME3@gmail.com",
"actived": false
}
]
- Open your postman application in localhost:8080/api/persons/{id}
- METHOD:DELETE
- BODY: EMPTY
- RETURN: 204 No Content