SpringBoot Rest Api tutorial with OpenApi 3.0 and Mysql. Yes, yet another tutorial with "book, author and publisher" as entities.
- Spring Boot Rest Api
- Swagger UI for visualizing APIs
- Error Handling
- JSON Web Token Authentication
- Mapper for POJO<->DTO
- 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
build/reports/checkstyle/main.html
build/reports/checkstyle/test.html
build/reports/tests/test/index.html
build/reports/jacoco/test/html/index.html
build/reports/dependency-check-report.html
build/reports/pitest/index.html
There is a docker compose file to run MySql and phpMyAdmin.
docker compose -f docker/docker-compose.yml up
- phpMyAdmin (http://localhost:8080/)
- gradle: ./gradlew bootRun
- fat jar: java -jar ./build/libs/books-1.0-SNAPSHOT.jar
java -Dendpoints.jmx.enabled=true \
-Dcom.sun.management.jmxremote.port=9999 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-jar ./build/libs/books-1.0-SNAPSHOT.jar
jconsole service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi
http://localhost:8081/swagger-ui.html
./gradlew jibDockerBuild
docker compose -f docker/docker-compose-all.yml up
cd books-integration-test/
./gradlew clean build