This is a simple project using a few Spring modules and Docker Compose to run the application. It will also demonstrates the usage of Spring Doc and the integration with PostgreSQL through Spring JPA. In addition, a few useful plugins to ensure the code quality are added to the project: Checkstyle, SpotBugs and FindBugsSec.
In order to run and compile the project correctly you will need:
- OpenJDK 13+
- Maven 3.5+
- Docker Desktop + Docker Compose
- Git
- Linux or MacOS
The project brings three files that are executable in Linux or Mac systems. They will help you to get started, debug and test your code. The following commands must be run in the root project directory. Before running the commands, you have to clone the project:
$ git clone https://github.com/maikelarabori/spring-boot-docker.git
$ sh run.sh
Once your embedded Jetty server is started you can fire requests against the endpoints through http://localhost:8080.
$ sh run-debug.sh
Now, connect in the port 5005 using the remote debug of your IDE. You're able to requests to http://localhost:8080 and debug as usual.
$ sh run-tests-check.sh
The build will fail if some test fails, or you have some code styling issue or possible bugs are found. Once this command runs successfully, the REST API documentation will be generated at spring-boot-docker/target/generated-docs/index.html.
To use the commands below you need to have cURL installed.
Registers a new user
curl -X POST \
http://localhost:8080/api/users \
-H 'Accept: application/json' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"email": "maikel@somemail.io",
"password": "Password1",
"username": "maikel",
"yearOfBirth": 1994
}'
Lists all users stored
curl -X GET \
http://localhost:8080/api/users \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache'
Feel free to make suggestions for fixes, improvements or contributing through pull requests.