Skip to main content

Sprint Boot (Java)

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". Sprint Boot take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need minimal Spring configuration.

In this guide you'll learn how to setup hot-reloading for Architect Components that use Spring Boot services.

services:
app:
build:
context: .
dockerfile: Dockerfile
debug:
build:
dockerfile: Dockerfile.dev
volumes:
# The name of the volume we are creating
app:
host_path: .
mount_path: /opt/code/src

Take a look at the architect.yml file cited above, and first note the use of a different dockerfile inside debug.build for your service. The production Dockerfile includes all the steps to build the application before being served directly from a .war file, but Dockerfile.dev skips all that and uses the command mvn spring-boot:run -Dspring.devtools.restart.enabled=true to build the application from source and ensure that it uses the spring devtools to continously reload the application when there are changes.

Secondly, the architect.yml file includes a volume to map the application source code to from the host to the container runtime. This ensures that code changes are visible to the docker container runtime so that spring boot can detect the changes.