SpringBoot 如何切换Thymeleaf模板引擎版本及对应布局版本呢?

Use Thymeleaf 3 官方文档

在pom.xml文件中添加以下配置

<properties>
  <thymeleaf.version>3.0.9.RELEASEthymeleaf.version>
          
       
  <thymeleaf-layout-dialect.version>2.3.0thymeleaf-layout-dialect.version>
properties>

如何找到这两项的配置呢?[官方文档已经告诉我们了]

找到spring-boot-dependencies这个文件,在里面找对应的配置即可

报错!!!

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call the method org.thymeleaf.spring5.SpringTemplateEngine.setRenderHiddenMarkersBeforeCheckboxes(Z)V but it does not exist. Its class, org.thymeleaf.spring5.SpringTemplateEngine, is available from the following locations:

    jar:file:/D:/OpenSources/MyRepository/org/thymeleaf/thymeleaf-spring5/3.0.9.RELEASE/thymeleaf-spring5-3.0.9.RELEASE.jar!/org/thymeleaf/spring5/SpringTemplateEngine.class

It was loaded from the following location:

    file:/D:/OpenSources/MyRepository/org/thymeleaf/thymeleaf-spring5/3.0.9.RELEASE/thymeleaf-spring5-3.0.9.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.thymeleaf.spring5.SpringTemplateEngine

解决方案:

<properties>
    <springboot-thymeleaf.version>3.0.9.RELEASEspringboot-thymeleaf.version>
    <thymeleaf-layout-dialect.version>2.3.0thymeleaf-layout-dialect.version>
properties>

问题分析:

这里用的是org.springframework.boot下的spring-boot-starter-thymeleaf,使用做标签时可能与org.thymeleaf有冲突,导致包获取不正确

你可能感兴趣的:(Java进化之旅,Spring,Boot)