Skip to content

An example of a REST API project using Spring Boot, Spring Security, Spring JPA, Spring Docs and Docker.

License

Notifications You must be signed in to change notification settings

maikelarabori/spring-boot-docker

Repository files navigation

About this project

Overview

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.

Prerequisites

In order to run and compile the project correctly you will need:

  1. OpenJDK 13+
  2. Maven 3.5+
  3. Docker Desktop + Docker Compose
  4. Git
  5. Linux or MacOS

Getting started

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

Running the project in development mode

$ sh run.sh

Once your embedded Jetty server is started you can fire requests against the endpoints through http://localhost:8080.

Debugging your project

$ 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.

Test, validate your code and prevent bugs

$ 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.

Example of implemented requests

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'

Contribution

Feel free to make suggestions for fixes, improvements or contributing through pull requests.

About

An example of a REST API project using Spring Boot, Spring Security, Spring JPA, Spring Docs and Docker.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published