For further reference, please consider the following sections:
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Create an OCI image
- Spring Web
- Spring Security
- Spring Data JPA
- Docker Compose Support
- Spring Boot DevTools
The following guides illustrate how to use some features concretely:
- Building a RESTful Web Service
- Serving Web Content with Spring MVC
- Building REST services with Spring
- Securing a Web Application
- Spring Boot and OAuth2
- Authenticating a User with LDAP
- Accessing Data with JPA
- Accessing data with MySQL
This project contains a Docker Compose file named compose.yaml.
In this file, the following services have been defined:
- mysql:
mysql:8.4.4
Please review the tags of the used images and set them to the same as you're running in production.
Due to Maven's design, elements are inherited from the parent POM to the project POM.
While most of the inheritance is fine, it also inherits unwanted elements like <license> and <developers> from the parent.
To prevent this, the project POM contains empty overrides for these elements.
If you manually switch to a different parent and actually want the inheritance, you need to remove those overrides.
- Java SE 17 or OpenJDK 17
- Docker Desktop
- MySQL 8.4.4 (if not using Docker)
NOTE: Everytime changes are made, a new image build and container build are required.
- Navigate to the
src/main/resources/directory. Make a copy ofapplication.properties.exampleand rename it toapplication.properties.
cd src/main/resources/
cp application.properties.example application.properties
The example properties file is already configured to use the configured Docker environment. Feel free to change any pre-existing settings to match your setup.
- Build the application image using the
build-imagemaven plugin
./mvnw spring-boot:build-image -DskipTests
- Spin up running containers for dependencies (including the image created in the previous step)
docker-compose up --build
I recently ran into the following issue:
Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.4.3:build-image failed: OS must not be empty
Sometimes stale cache layers cause strange issues. Using docker system prune -af addressed the issue above and will clean the Docker build cache. Be careful — this removes all stopped containers, unused networks, and dangling images.