This repository is a starter template for developing Java Spring Boot applications with hot reload support, fully containerized with Docker and Docker Compose. It provides everything you need to quickly start building and testing REST APIs with a modern workflow.
- Spring Boot demo project (REST endpoint at
/hello) - Dockerfile + Dockerfile.dev for production and development builds
- Docker Compose setup for running the app in containers
- Hot reload: Change source code and instantly see updates by refreshing the endpoint
- Preconfigured Gradle build
- Includes basic
.dockerignoreand.gitignorefiles
- Clone this repository
git clone https://github.com/cjmyles/docker-java-spring-boot-hot-reload.git
cd docker-java-spring-boot-hot-reload- Build & run using Docker Compose
docker compose up --build- Access the demo endpoint
- Visit http://localhost:8080/hello in your browser. You should see the Hello, World! response.
- Hot Reload Setup
- While the app is running, modify
src/main/java/com/example/demo/HelloWorldController.java - Save your changes and refresh http://localhost:8080/hello to see updates.
├── Dockerfile
├── Dockerfile.dev
├── docker-compose.yaml
├── docker-compose.override.yaml
├── build.gradle
├── gradle/
│ └── wrapper/
├── src/
│ └── main/java/com/example/demo/HelloWorldController.java
├── .dockerignore
├── .gitignore
└── settings.gradle
- Run in Production
- Use the default
Dockerfilefor optimized production builds.
- Use the default
- Run in Development Mode
- Use
Dockerfile.devfor faster builds and hot reload during local development.
- Use
- Extend Configuration
- Adjust Compose files or Dockerfiles as needed for your own projects.
- Ensure Docker and Docker Compose are installed and running.
- On changes not reflecting, check that the container is using the development Dockerfile and volumes are correctly mounted.
- Check container logs for errors using:
docker compose logsPull requests and suggestions are welcome! Open an issue or contribute new features, improvements, or documentation.
MIT