This project is a starter template to create a Spring Boot REST API. It consists of a basic CRUD application for Customers, Orders and Products entities.
This project uses H2 Database. H2 is an in memory relational database built in Java.
More information: https://www.h2database.com/html/main.html
| Column | Type | Nullable |
|---|---|---|
| id | Long | false |
| name | String | false |
| individualTaxpayerRegistry | String | false |
| orders | Set<Order> | false |
| Column | Type | Nullable |
|---|---|---|
| id | Long | false |
| description | String | true |
| customer | Customer | true |
| Column | Type | Nullable |
|---|---|---|
| id | Long | false |
| name | String | true |
| description | String | true |
| price | BigDecimal | false |
-
Run the command
docker build -t <image_tag> .Or
docker build -t <image_tag> -f Dockerfile.windows .for Windows.The Windows specific Dockerfile was created because of a problem with DOS line endings in the
mvnwfile so it uses thedos2unixdependency inside the image. -
Run the command
docker run -p 8080:8080 <name_of_the_image>. By default the application will start at port 8080.The port can be changed in the
application.propertiesfile, in theserver.portproperty.The
application.propertiesfile is placed inside the Docker image, so the container will start with these configs as default.
-
Install Java (JDK 11).
-
Download H2 Database at http://www.h2database.com/html/download.html.
-
Run
.\mvnw spring-boot:runin the root of the project..\mvnwis a wrapper for the correct Maven version. You can learn more about ir here: https://www.baeldung.com/maven-wrapper
-
Run
.\mvnw testin the root of the project.Currently the API uses Basic Authentication provided by Spring Security. And creates a default user with username:
userand password:pass. These values are currently hardcoded in the tests code so they can run successfully.
The API is documented using Swagger. To access the generated documentation first run the app and then go to http://localhost:8080/swagger-ui.html#/ where you will be presented with the Swagger UI (it also allows you to test the endpoints).
More on Swagger: https://swagger.io/
-
- This is a finished version that offers a template for a basic CRUD app, with Docker. Without authentication.
- Create env variables file