Spring Boot and Thymeleaf 3.0.0.RELEASE integration

19,162

Solution 1

It's much simpler, just read this: http://docs.spring.io/spring-boot/docs/1.5.x/reference/htmlsingle/#howto-use-thymeleaf-3

<properties>
    <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
    <thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>

Solution 2

As stated in the documentation for 1.4.7.RELEASE: https://docs.spring.io/spring-boot/docs/1.4.7.RELEASE/reference/htmlsingle/#howto-use-thymeleaf-3


If you use Gradle put this in the build.gradle file:

Gradle: build.gradle

ext['thymeleaf.version'] = '3.0.2.RELEASE'
ext['thymeleaf-layout-dialect.version'] = '2.1.1'

If you use Maven put this in the pom.xml file:

Maven: pom.xml

<properties>
    <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
    <thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>

(since I have not enough reputation, I posted an answer instead of a comment on one of the previous answers. Especially the build.gradle part.)

Solution 3

spring boot 1.4.0 + thymeleaf 3.0.1

    <dependency>
        <groupId>org.thymeleaf</groupId>
        <artifactId>thymeleaf</artifactId>
        <version>3.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.thymeleaf</groupId>
        <artifactId>thymeleaf-spring4</artifactId>
        <version>3.0.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>nz.net.ultraq.thymeleaf</groupId>
        <artifactId>thymeleaf-layout-dialect</artifactId>
        <version>2.0.3</version>
    </dependency>

Solution 4

For Maven project just add following line on pom.xml

<properties>
    <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
    <thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>

For gradle project create a gradle.properties file with following contents

thymeleaf.version=3.0.2.RELEASE
thymeleaf-layout-dialect.version=2.1.1
Share:
19,162
przodownikPracy
Author by

przodownikPracy

Updated on July 28, 2022

Comments

  • przodownikPracy
    przodownikPracy almost 2 years

    I have a problem, when I try integrate Spring Boot 1.3.5.RELEASE and Thymeleaf 3.0.0.Release. I know that Spring Boot now support Thymeleaf 3 version so I try workaround this problem like this :

    @SpringBootApplication(exclude={org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration.class})
    

    and add my own SpringWebConfig configuration. unfortunately received error like this :

    java.lang.ClassNotFoundException: org.thymeleaf.resourceresolver.IResourceResolver
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_66]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_66]
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_66]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_66]
        ... 37 common frames omitted
    Wrapped by: java.lang.NoClassDefFoundError: org/thymeleaf/resourceresolver/IResourceResolver
    
    
    
    wrapped by: java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration due to org/thymeleaf/resourceresolver/IResourceResolver not found. M                                                                                                        ake sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
    
  • przodownikPracy
    przodownikPracy almost 8 years
    Thanks very much for your help, I am a little confused by this configuration and integration Thymeleaf and Spring Boot. But the problem remains.... Temporarily in the target project back to a previous version thymeleaf. Below a link to a proof on concept of this solution. There is a full configuration and dependencies. [link] github.com/przodownikR1/voteEngine
  • ekad
    ekad over 7 years
    Please also add some explanation of how the above code solves the problem.
  • Sergey Vyacheslavovich Brunov
    Sergey Vyacheslavovich Brunov over 7 years
    This has helped. The case: Spring Boot is used as a POM-import dependency, not the parent POM.
  • lilalinux
    lilalinux about 7 years
    Better use the properties of Henrique's answer
  • Samuel EUSTACHI
    Samuel EUSTACHI almost 7 years
    You might also want to add <thymeleaf-extras-java8time.version>3.0.0.RELEASE</thymeleaf‌​-extras-java8time.ve‌​rsion>