Some experimentation with Spring Boot 2, JDK8+, JUnit5, TestNG, SQL, NoSQL, Docker, ELK stack, etc. It demonstrates usage of:
- Maven (latest version) and Gradle build tools
- migration from Maven to Gradle (but I'll stick to Maven). Stable and functional, but still needs some improvements. See commit cf79b9c (spring5-mvn-to-gradle branch)
- Spring Boot 2 (Spring Framework 5)
- built with JDK11 on Travis CI, targets JRE8 bytecode. See commit f778bf0 (spring5-light-jre8-with-jdk11 branch)
- Spring Web with a REST API
- Spring Security, to authenticate users via auth_basic and fetch authentication data from SQL database
- Spring Data to serve data from a MongoDB database
- Spring Batch to schedule and manage some tasks. See commit c0e3422 (spring5-light-batch branch)
- Spring Cache via Redis for application, and prefer an embedded cache provider during tests. See commits a911f6a, 7e26822 and ae6e0e6 (spring5-redis branch)
- integration tests and (some) unit-test via JUnit5 and REST Assured. I prefer TestNG for its keywords, dataproviders and maturity, but JUnit is the most used testing framework. REST Assured helped me to test API without Spring's magic
- migration from TestNG to JUnit5 (with Spring Boot, dataproviders, expected exceptions, beforeClass and afterClass annotations). See last commit of spring5-light-testng-to-junit5 branch
- Java architecture tests via ArchUnit. See last commit of spring5-light-archunit branch
- use dockerized MariaDB on Travis CI instead of embedded HSQLDB. See last commit of spring5-light-travis-with-mariadb branch
- migration from MongoDB (used to store regular and authentication data) to MariaDB. See last commit of spring5-light-mongo-to-sql branch
- tests work with an embedded MongoDB instance (for data) and HSQLDB (for Spring Batch internals only), that means you don't have to install any database to test project
- use embedded MongoDB during tests. See commits 37e1be5 and 161d321 (spring5-embedmongo branch)
- make embedded MongoDB work with version from 3.6 to 4.0: see commit a75a917 (spring5-light-mongo4.0.x branch)
- replace HSQLDB by H2. See commit ae4701e (spring5-light-hsqldb-to-h2 branch)
- tests work with an embedded MongoDB instance (for data) and HSQLDB (for Spring Batch internals only), that means you don't have to install any database to test project
- migration to Java 8 new Date and Time API (JSR-310). See last commit of spring5-light-java8-datetime-api branch
- integration with some free (for open-source) services like AppVeyor (Windows CI), Travis (Linux and MacOS CI), Cirrus (CI), CodeCov (code coverage), SonarCloud (code quality), LGTM (code quality)
- Maven and Gradle wrappers, and a
doBash script that helps you to launch some usefull commands - code coverage thanks to JaCoCo Maven and Gradle plugin
- some AOP to capture performance of API endpoints
- Spring Actuator web endpoints configured
- Swagger UI to provide documentation about REST API endpoints
- run application and check
http://localhost:8080/swagger-ui.html, authenticate withROOT/woot. See commit 834852c (spring5-swagger branch)
- run application and check
- Docker builds without Docker daemon thanks to Jib. Docker Compose support. Linux base image is Distroless
- See DEPLOY.md to package and run application. See commit de7335b (spring5-light-docker-jib branch)
- ELK stack (ElasticSearch Logstash Kibana) via Docker plus Docker Compose to parse application and Nginx logs, and Cerebro to monitor ElasticSearch node
- see DEPLOY.md to package and run application. Also, see commits 6b76e37 and 966969f (spring5-light-elk branch)
- integration with SpotBugs (FindBugs)
- Spring Boot dependency management without Spring Boot parent POM. See last commit of spring5-light-spring-boot-dependencies branch
For fun and to show some skills 🐱
Jonathan Lermitage (jonathan.lermitage@gmail.com)
Linkedin profile: jonathan-lermitage-092711142
First, install JDK11 and Maven3+.
You can now use the ./do Linux Bash script:
do help show this help message
do t test without code coverage (with embedded MongoDB)
do tc test with code coverage (with embedded MongoDB)
do sc compute and upload Sonar analysis to SonarCloud
do tsc similar to "do tc" then "do sc"
do sb scan with SpotBugs then show GUI
do b build without testing
do c clean
do p package application to manon.jar
do rd package and run application with dev profile
do w 3.5.2 set or upgrade Maven wrapper to 3.5.2
do cv check plugins and dependencies versions
do uv update plugins and dependencies versions
do dt show dependencies tree
do rmi stop Docker application, then remove its containers and images
do cdi clean up dangling Docker images
do docker build Docker image with Dockerfile to a Docker daemon
do jib build Docker image with Jib to a Docker daemon
do jibtar build and save Docker image with Jib to a tarball
do up create and start containers via docker-compose
do stop stop containers via docker-compose
do upelk create and start ELK containers via docker-compose
do stopelk stop ELK containers via docker-compose
do upcerebro create and start Cerebro container via docker-compose
do stopcerebro stop Cerebro container via docker-compose
Nota: the Linux Bash script can chain parameters, e.g.: ./do cdi rmi w 3.6.0 c tc docker up.
Nota: a Windows do.cmd script exists, but it's limited to some basic features (do t to do dt, no Docker support).
MIT License. In other words, you can do what you want: this project is entirely OpenSource, Free and Gratis.