Fix Thymeleaf HTML5 parsing in Spring Boot

This post is about fixing “Fatal error during parsing” HTML5 by Thymeleaf with Spring Boot.

Using Spring Boot 1.5.10.RELEASE with Thymeleaf and HTML5, it is possible to meet the following error:

org.xml.sax.SAXParseException: The element type "meta" must be terminated by the matching end-tag "</meta>".

Example HTML5:

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <title>Page Title</title>
Page Body

It happens because spring-boot-starter-thymeleaf:1.5.10.RELEASE has default dependency on org.thymeleaf:thymeleaf-spring4:2.1.6.RELEASE. Fix needs updated version of Thymeleaf.

To make this, it is enough to define the following 2 properties in pom.xml:


Or, in case of using Gradle, add them in build.gradle:

ext['thymeleaf.version'] = '3.0.9.RELEASE'
ext['thymeleaf-layout-dialect.version'] = '2.3.0'