spring boot thymeleaf切换版本

新版的spring boot切换版本老是报错,前段时间解决了,忘 了,重新搜索了一下,记录一下:

原文地址:https://blog.csdn.net/Mr_Mocha/article/details/97419945

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

<properties>
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
<!-- 布局功能的支持程序 thymeleaf3主程序 对应 layout2以上版本 -->
<!-- thymeleaf2 对应 layout1版本 -->
<thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version>
</properties>
1
2
3
4
5
6
如何找到这两项的配置呢?[官方文档已经告诉我们了]

找到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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
解决方案:

<properties>
<springboot-thymeleaf.version>3.0.9.RELEASE</springboot-thymeleaf.version>
<thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version>
</properties>
1
2
3
4
问题分析:

这里用的是org.springframework.boot下的spring-boot-starter-thymeleaf,使用<thymeleaf.version>做标签时可能与org.thymeleaf有冲突,导致包获取不正确
————————————————
版权声明:本文为CSDN博主「摩卡先生」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Mr_Mocha/article/details/97419945

原文地址:https://www.cnblogs.com/linwenbin/p/11441336.html