SpringBoot Rest Api tutorial with OpenApi 3.0 and PostgreSql.
- Spring Boot Rest Api
- Swagger UI for visualizing APIs
- Error Handling
- Basic Authentication
- Mapper for POJO<->DTO
- Actuator
- Eureka server and Open Feign
- Gateway
- Logging
- Testing
- Repositories using DataJpaTest
- Services using Mockito
- EndPoints using WebMvcTest
- Pojos and Dtos using OpenPojo
- End to End Test with TestRestTemplate
- Integration test using TestContainers and Cucumber
./gradlew clean build
./gradlew dependencyCheckAnalyze --info
./gradlew pitest
Run SonarQube
docker-compose -f docker/docker-compose-sonar.yml up
- Sonarqube (http://localhost:9000/)
For SonarQube configuration follow this link: Try Out SonarQube
Scan project
./gradlew sonarqube \
-Dsonar.projectKey=yourProjectKey \
-Dsonar.token=yourAuthenticationToken
company-api/build/reports/checkstyle/main.html
company-api/build/reports/checkstyle/test.html
company-api/build/reports/tests/test/index.html
company-api/build/reports/jacoco/test/index.html
company-api/build/reports/pitest/index.html
company-api/build/reports/dependency-check-report.html
company-dto/build/reports/checkstyle/main.html
company-dto/build/reports/checkstyle/test.html
company-dto/build/reports/tests/test/index.html
company-dto/build/reports/jacoco/test/index.html
company-dto/build/reports/pitest/index.html
company-dto/build/reports/dependency-check-report.html
product-api/build/reports/checkstyle/main.html
product-api/build/reports/checkstyle/test.html
product-api/build/reports/tests/test/index.html
product-api/build/reports/jacoco/test/index.html
product-api/build/reports/pitest/index.html
product-api/build/reports/dependency-check-report.html
product-common/build/reports/checkstyle/main.html
product-common/build/reports/checkstyle/test.html
product-common/build/reports/tests/test/index.html
product-common/build/reports/jacoco/test/index.html
product-common/build/reports/pitest/index.html
product-common/build/reports/dependency-check-report.html
product-dto/build/reports/checkstyle/main.html
product-dto/build/reports/checkstyle/test.html
product-dto/build/reports/tests/test/index.html
product-dto/build/reports/jacoco/test/index.html
product-dto/build/reports/pitest/index.html
product-dto/build/reports/dependency-check-report.html
product-eureka/build/reports/checkstyle/main.html
product-eureka/build/reports/checkstyle/test.html
product-eureka/build/reports/tests/test/index.html
product-eureka/build/reports/jacoco/test/index.html
product-eureka/build/reports/dependency-check-report.html
product-gateway/build/reports/checkstyle/main.html
product-gateway/build/reports/checkstyle/test.html
product-gateway/build/reports/tests/test/index.html
product-gateway/build/reports/jacoco/test/index.html
product-gateway/build/reports/dependency-check-report.html
./gradlew jibDockerBuild
-
Applications in java command:
docker-compose -f docker/docker-compose.yml up java -jar ./product-api/build/libs/product-api-1.0-SNAPSHOT.jar java -jar ./company-api/build/libs/company-api-1.0-SNAPSHOT.jar
-
All applications in docker:
docker compose -f docker/docker-compose.yml -f docker/docker-product.yml up
-
All applications in docker with Prometheus and Grafana:
docker compose -f docker/docker-compose.yml -f docker/docker-product.yml -f docker/docker-extension.yaml up
Links
- http://localhost:8080 (pgAdmin)
- http://localhost:8761 (Eureka)
- http://localhost:3007/swagger-ui.html (Gateway)
- http://localhost:3080 (Grafana)
- Basic Authentication
- Company Api: (companyUser/companyPassword)
- Product Api: (productUser/productPassword)
- Eureka: (eurekaUser/eurekaPassword)
- pgAdmin: (product@domain-name.com/secret)
- Gateway: (gatewayUser/gatewayPassword)
- Grafana: (admin/grafana)
curl 'http://localhost:8082/actuator/info' -i -X GET
curl 'http://localhost:8082/actuator/health' -i -X GET
curl 'http://localhost:8082/actuator/prometheus' -i -X GET
curl 'http://localhost:8081/actuator/info' -i -X GET
curl 'http://localhost:8081/actuator/health' -i -X GET
curl 'http://localhost:8081/actuator/prometheus' -i -X GET
./gradlew publishToMavenLocal
cd product-integration-test
./gradlew clean build
- Gradle 8.5
- Java 17
- Spring Boot 3.3
- Spring Security
- Swagger OpeApi 3.0
- Micrometer Prometheus 1.13
- Mapstruct 1.5
- Lombok 1.18
- Spring Data JPA
- org.postgresql 42.7
- HsqlDb
- LogBack 1.5
- Mockito
- JUnit 5
- OpenPojo 0.9
- CheckStyle 8.44
- Owasp Dependency Check 8.4
- Jacoco 0.8
- Pitest 1.15
- TestContainers 1.20
- Cucumber 7.18