This post walks you through the steps of creating a Hello World example with Spring Boot, Thymeleaf and Docker.

Spring Boot View Templates Hello World Example Series:
- Spring Boot Hello World Example with FreeMarker
- Spring Boot Hello World Example with Thymeleaf
- Spring Boot Hello World Example with JSP

What you'll build

What you'll need

  • Docker CE 18+

Project structure

Project dependencies


Hello Controller

Controller maps HTTP Requests with View.


@RequestMapping maps /hello request to hello() method.

name is a query string parameter of /hello request.

Model object passes value to hello view (hello.ftl).

View Template


Static files



Application Configuration



Run with Maven

Type this bash command at the example root directory

mvn clean spring-boot:run

Run with Docker

Prepare Dockerfile for Java/Spring Boot application


Start your application and infrastructure via Docker Compose. Make sure your local Docker is running and your bash console is at the springboot-examples project root directory.

docker-compose -f docker-compose-view.yaml up --renew-anon-volumes thymeleaf-helloworld

Source code

https://github.com/hellokoding/springboot-examples/tree/master/view-templates/thymeleaf-helloworld

Spring Boot View Templates Hello World Example Series:
- Spring Boot Hello World Example with FreeMarker
- Spring Boot Hello World Example with Thymeleaf
- Spring Boot Hello World Example with JSP