As described in the Spring documentation, when using thymeleaf 3 with Spring Boot, if parent is spring-boot-starter-parent, you can use it by specifying it in properties like this.
<properties>
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>
However, spring-boot-starter-parent cannot be specified as parent when the company has decided the pom to be specified as parent. In that case, the setting to use thymeleaf 3 was complicated, so make a note of it.
Also in here Although it is written, if it is not specified as parent, write spring-boot-dependency in <dependencyManagement>
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.6.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
What it does is specify the version of dependencies required by Spring Boot.
The one that enters by default is written in here or in the pom of the head family.
If you continue to use it, thymeleaf 2.1.5 will be installed. Since I want to use 3, write the version of the module you want to change before spring-boot-dependencies of <dependencyManagemet>
and overwrite it.
<properties>
<spring-boot.version>1.5.6.RELEASE</spring-boot.version>
<thymeleaf.version>3.0.7.RELEASE</thymeleaf.version>
<thymeleaf-spring4.version>3.0.7.RELEASE</thymeleaf-spring4.version>
<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>${thymeleaf.version}</version>
</dependency>
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
<version>${thymeleaf-layout-dialect.version}</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>${thymeleaf-spring4.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
It is like this.
If you just write in <dependencyManagement>
, the essential module will not be installed, so
I will write the module to be installed in <dependencies>
.
<dependencies>
<dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
</dependency>
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
</dependency>
</dependencies>
Like this!
If spring-boot-starter-thymeleaf
is written in pom, delete it.
At first I wanted to use LocalDateTime with thymeleaf, so I put thymeleaf-extras-java8time, but
When from is null in #temporals.format (from,'yyyyMMdd')
, ʻIllegalArgumentException: Cannot apply format on nullappears in the 2nd system and it is difficult to use 3.0. I found that it was solved in 1. [This](https://github.com/thymeleaf/thymeleaf-extras-java8time/issues/14) However, the 3 system of thymeleaf-extras-java8time must be thymeleaf 3, so for the time being, if I thought that I should set the version of thymeleaf to 3 in properties, I got an error like
ClassNotFoundException IExpressionObjectDialect` and I will investigate It seems that the version was still thymeleaf 2 when I just specified it in properties.
Recommended Posts