概要
Spring Boot 1.4で使用されるデフォルトのThymeleafはバージョンが2系である。これは、テンプレートをXMLとしてパースするため、閉じタグが必須であるなど、かなり厳密に記述する必要がある。
一般的なHTML5の構文で記述したい場合は、Thymeleafを3系にすることで対応することができる。
Thymeleaf 3系にする
build.gradleでthymeleaf.version
に3系のバージョンを設定する。
dependencies {
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
// 略
}
ext['thymeleaf.version'] = '3.0.3.RELEASE'
ext['thymeleaf-layout-dialect.version'] = '2.1.2'
ext['thymeleaf-extras-java8time.version'] = '3.0.0.RELEASE'
ext['thymeleaf-extras-data-attribute.version'] = '2.0.1'
他のオプションは必要に応じて設定する。