{"id":22191695,"url":"https://github.com/leosimoes/udemy-java-quarkus-restapi-products","last_synced_at":"2026-05-11T02:16:05.909Z","repository":{"id":195218644,"uuid":"692481310","full_name":"leosimoes/Udemy-Java-Quarkus-RESTApi-Products","owner":"leosimoes","description":"Course project \"Quarkus Framework with REST APIs\" from Udemy. REST API in Java with Quarkus Framework for CRUD of products.","archived":false,"fork":false,"pushed_at":"2023-09-17T19:50:19.000Z","size":778,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T01:16:46.198Z","etag":null,"topics":["crud","gradle","java","quarkus","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leosimoes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-16T16:00:12.000Z","updated_at":"2023-12-06T22:07:51.000Z","dependencies_parsed_at":"2023-09-17T03:18:00.463Z","dependency_job_id":null,"html_url":"https://github.com/leosimoes/Udemy-Java-Quarkus-RESTApi-Products","commit_stats":null,"previous_names":["leosimoes/udemy-java-quarkus-restapi-products"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FUdemy-Java-Quarkus-RESTApi-Products","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FUdemy-Java-Quarkus-RESTApi-Products/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FUdemy-Java-Quarkus-RESTApi-Products/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FUdemy-Java-Quarkus-RESTApi-Products/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leosimoes","download_url":"https://codeload.github.com/leosimoes/Udemy-Java-Quarkus-RESTApi-Products/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245351758,"owners_count":20601089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crud","gradle","java","quarkus","rest-api"],"created_at":"2024-12-02T12:17:20.073Z","updated_at":"2026-05-11T02:16:00.883Z","avatar_url":"https://github.com/leosimoes.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Udemy - Quarkus Framework with REST API's\n![Quarkus-Logo](/imgs/Img-0-QuarkusLogo.png)\n\nUdemy's \"Quarkus Framework with REST APIs\" course project: Product Rest API.\n\n| Technology | Version |\n|------------|---------|\n| Gradle     | 8.1.1   |\n| Java       | 17.0.6  |\n| Quarkus    | 3.3.3   |\n\n\n## Steps\n1. Create the project in IntelliJ:\n- Language: Java\n- Group: com.restapi\n- Artifact: products\n- JDK: 17 (or other)\n- Quarkus: 3.3.3\n- Extensions:\n    * RestEasy Reactive Jackson\n    * Hibernate ORM with Panache\n    * JDBC Driver - H2\n    * SmallRye OpenAPI\n    * SmallRye Health\n\n![Starter-Project](/imgs/Img-1-Starter.jpg)\n\n2. Build the project:\n\n![Build-Project](/imgs/Img-2-Build.jpg)\n\n3. Run the project, without modifying it yet, and check the main url:\n- http://localhost:8080/\n\n![Run-Project](/imgs/Img-3-Run.jpg)\n\n4. Configure the database (H2) in `application.properties`.\n````\n# H2 Database Configuration\nquarkus.datasource.db-kind=h2\nquarkus.datasource.jdbc.driver=org.h2.Driver\nquarkus.datasource.username=usuario\nquarkus.datasource.password=senha\nquarkus.datasource.jdbc.url=jdbc:h2:mem:default\nquarkus.hibernate-orm.database.generation=drop-and-create\n````\n\n5. Create the `ProductEntity` class:\n- inside the `entities` package;\n- annotate with `@Entity`, `@Table`;\n- the table name must be \"product\";\n- attributes must be: `id`, `name`, `description`, `category`, `model`, `price`, `creationDate`, `updateDate`.\n- The `id` must be annotated with `@Id` and `@GeneratedValue`.\n- The `creationDate` must be annotated with `@CreationTimestamp`.\n- The `updateDate` must be annotated with `@UpdateTimestamp`.\n- See step 8.\n\n![Class-ProductEntity](/imgs/Img-4-Class-ProductEntity-b.jpg)\n\n6. Add Lombok:\n- In `build.gradle` add the Lombok dependencies:\n```\ncompileOnly 'org.projectlombok:lombok:1.18.28'\nannotationProcessor 'org.projectlombok:lombok:1.18.28'\ntestCompileOnly 'org.projectlombok:lombok:1.18.28'\ntestAnnotationProcessor 'org.projectlombok:lombok:1.18.28'\n```\n- Install the Lombok plugin in IntelliJ.\n\n![IntelliJ-Plugin-Lombok](/imgs/Img-5-IntelliJ-Plugin-Lombok.jpg)\n\n- Rebuild the project.\n- Annotate the `ProductEntity` class with `@Data`, `@NoArgsConstructo` and `@AllArgsConstructor`.\n\n7. Create the `ProductDTO` class:\n- inside the `dtos` package;\n- attributes must be of type `String`: `name`, `description`, `category`, `model`, `price`.\n- use `@Data`, `@NoArgsConstructo` and `@AllArgsConstructor` notations.\n\n![Class-ProductDTO](/imgs/Img-6-Class-ProductDTO-b.jpg)\n\n8. Update the `ProductEntity` class:\n- annotate the class with `@Builder`;\n- the class must extend `PanacheEntity`;\n- remove or comment out the explicit declaration of `id`.\n\n9. Create the `ProductMapper` interface:\n- In `build.gradle` add the MapStruct dependencies:\n```\nimplementation 'org.mapstruct:mapstruct:1.5.5.Final'\nannotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'\n```\n- rebuild the project.\n- inside the `mappers` package;\n- use `@Mapper` annotation;\n- declare the methods `ProductDTO toDTO(ProductEntity productEntity)` and `ProductEntity toEntity(ProductDTO productDTO)`;\n- declare the methods `List\u003cProductDTO\u003e toDTOList(List\u003cProductEntity\u003e productEntities);` and `List\u003cProductEntity\u003e toEntityList(List\u003cProductDTO\u003e productDTOs);`\n- put attribute `ProductMapper INSTANCE = Mappers.getMapper(ProductMapper.class);`;\n\n![Interface-ProductMapper](/imgs/Img-7-Interface-ProductMapper.jpg)\n\n10. Create the `ProductRepository` class:\n- inside the `repositories` package;\n- annotate with `@ApplicationScoped`;\n- `public class ProductRepository implements PanacheRepository\u003cProductEntity\u003e {}`;\n- can be used for custom queries implementing methods;\n- see step 4.\n\n11. Create the `ProductService` class:\n- inside the `services` package;\n- use `@ApplicationScoped` annotation;\n- add attributes `private final ProductRepository productRepository` and `private final ProductMapper productMapper`;\n- the constructor must receive two attributes and be annotated with `@Inject`;\n- create methods `createProduct`, `getAllProducts`, `getProductById`, `updateProduct`, `deleteProduct`;\n- some of the methods, or the class, must be annotated `@Transactional`.\n\n![Class-ProductService](/imgs/Img-8-Class-ProductService.jpg)\n\n12. Create the `ProductResource` class:\n- inside the `resources` package;\n- use annotation `@Path(\"/api/products\")`, `@Produces(MediaType.APPLICATION_JSON)` and `@Consumes(MediaType.APPLICATION_JSON)`\n  For the class;\n- add the attribute `private final ProductService productService`;\n- the constructor must receive `productService` and be annotated with `@Inject`;\n- create methods `createProduct()`, `getAllProducts()`, `getProductById()`, `updateProduct()`, `deleteProduct()`;\n- public methods must be annotated according to the HTTP verb they implement: `GET`, `POST`, `PUT` or `DELETE`;\n- some methods must be annotated with `@Path(\"/{id}\")`.\n\n![Class-ProductResource](/imgs/Img-9-Class-ProductResource-b.jpg)\n\n13. Test the API at http://localhost:8080/q/swagger-ui/\n\n\n## References\nUdemy - Quarkus Framework with REST APIs - Vinícius Pereira de Oliveira:\nhttps://www.udemy.com/course/quarkus-rest-api/, accessed on 09/16/2023.\n\nProject Lombok - Setup - Gradle:\nhttps://projectlombok.org/setup/gradle , accessed on 09/16/2023.\n\nMapStruct - Documentation - Installation:\nhttps://mapstruct.org/documentation/installation/ , accessed on 09/16/2023.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleosimoes%2Fudemy-java-quarkus-restapi-products","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleosimoes%2Fudemy-java-quarkus-restapi-products","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleosimoes%2Fudemy-java-quarkus-restapi-products/lists"}