Spring Boot app showcasing several features of Spring and also using cool tools such as Prometheus and Grafana, all set up with Docker
The project was developed using Spring Boot 2.4 and Java 11.
- TLDR: you need docker to run the application.
The container for this application with all services can be found on Docker Hub at https://hub.docker.com/r/psatler/springboot2-essentials.
You can also follow the steps below to run this application:
git clone https://github.com/psatler/spring-boot-essentials.git
cd spring-boot-essentials
docker-compose up
This project has authentication enabled. You can authentication yourself by accessing the
http://localhost:8080/login
endpoint. Two example accounts are shown at the protected endpoints section below. To logout of the application, just access http://localhost:8080/logout
.
- Main application: accessed on
http://localhost:8080
- you can find the swagger on
http://localhost:8080/swagger-ui.html
- you can find the swagger on
- Prometheus: accessed on
http://localhost:9090
- Grafana: accessed on
http://localhost:3000
- at grafana's login page, the credentials are:
- username: admin
- password: admin
- at grafana's login page, the credentials are:
If you, like me, use DBeaver for browsing the database, you might get this Public Key Retrieval is not allowed error, which can be solved at this link.
In the prometheus.yml file you need to modify the IP in the static_configs
, line 27, to the IP of the machine you are running this application on. I used this on a Linux machine (Ubuntu 18.04)
mvn install
java -jar target/springboot2-essentials-0.0.1-SNAPSHOT.jar
All endpoints but the ones starting with /actuator/
(for example, /actuator/info
) are protected by some sort of basic authentication. The security configuration can be found at SecurityConfig class.
An example user you can use is
-
admin role:
- username: admin2
- password: devdojo-pass
-
user role:
- username: devdojo2
- password: devdojo-pass
You can run the integration test profile created by using the command below
mvn test -Pintegration-tests
Notes taken throughout the implementation of this can be found at Spring-Boot-2-Notes.md.
- Other DevDojo's playlists and videos on youtube
- Spring Boot JPA Tutorial by Amigoscode
- Courses from AmigosCode's website
- Java Testing with JUnit 5 by Freecodecamp