Spring Boot: Spring Boot 1.4.x & Thymeleaf 3.x configuration

David Marko
Feb 6, 2017 · 1 min read

Thymeleaf is quite popular template engine widely used among Spring Boot developers. And we use it as well. While working with Spring Boot 1.4.x you will find that spring-boot-starter-thymeleaf is based on older Thymeleaf 2.x version, while there is Thymeleaf 3.x available for some time.

But wait, there is an easy way how to get latest Thymeleaf for my Spring Boot 1.4.x application. There are 3 simple steps to do so.

  1. Reference Thymeleaf in build.gradle file (assuming we have Gradle based Spring Boot project)
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile ("org.thymeleaf.extras:thymeleaf-extras-springsecurity4:3.0.0.RELEASE")
compile ("io.github.jpenren:thymeleaf-spring-data-dialect:3.1.1")

2. Specify Thymeleaf version in build.gradle file Here is the place to say that we want version 3.x of Thymeleaf library

ext["thymeleaf.version"] = "3.0.2.RELEASE"
ext["thymeleaf-layout-dialect.version"] = "2.0.1"

3. (Optional) Create @Configuration class with Thymeleaf configuration options. Spring Boot with detect this and create appropriate beans.

David Marko

Written by

long time … husband, father, Christ follower, developer