This repository provides a lean dev container template for Java and Spring Boot projects.
It includes:
- a dev container based on Liberica OpenJDK 25
- a practical set of VS Code extensions for Java, Spring, YAML, and REST requests
- a persistent Maven cache backed by a Docker volume
- a lightweight container setup without a globally installed Maven
- VS Code
- the
Dev Containersextension - a running Docker-compatible engine such as Docker Desktop or OrbStack
There are two intended ways to use this setup.
Copy the .devcontainer folder from this repository into the root directory of your existing project.
Example:
my-spring-project/
.devcontainer/
devcontainer.json
Dockerfile
mvnw
pom.xml
src/
After that:
- Open the project folder in VS Code.
- If needed, reload or restart VS Code.
- Confirm the
Reopen in Containerprompt or runDev Containers: Reopen in Container. - VS Code builds the image and starts the development container.
During the first start, the postCreateCommand is executed. If an mvnw file exists, it is made executable and verified.
If you want to start new projects with the same baseline setup, you can use this repository as a template repository.
Typical flow:
- Select
Use this templateon GitHub. - Create a new repository from this template.
- Add your project code to the new repository.
- Open the generated repository in VS Code.
- Start the container via
Reopen in Container.
This is useful if you want the same starting point for every new Java/Spring project.
When you open the project folder in VS Code and start the dev container, the following happens:
- VS Code detects
.devcontainer/devcontainer.json. - The image is built from
.devcontainer/Dockerfile. - The project folder is mounted into the container under
/workspaces/<project-name>. - The Docker volume
maven-cacheis mounted to/home/vscode/.m2. - The configured extensions are installed inside the container.
- The VS Code settings from
devcontainer.jsonare applied for the container session.
- Maven is not installed globally inside the container. Projects are expected to use the Maven Wrapper (
mvnw). - After changing
Dockerfileordevcontainer.json, runDev Containers: Rebuild Container. - The
maven-cachevolume is created only when the container is built or started for the first time.
.devcontainer/devcontainer.json: VS Code and container configuration.devcontainer/Dockerfile: base image and required tools inside the container