您的位置:首页 > 编程语言 > Java开发

springboot 整合thyleaf中spring-boot-starter-parent版本问题。

2018-12-23 20:58 519 查看
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xy3962288/article/details/85225982

  在学习springboot引入thymeleaf的时候,遇到了一个问题,示例中spring-boot-starter-parent的版本是1.5.10.RELEASE,而本人在练习的时候建里一个springboot的项目,spring-boot-starter-parent的版本是2.1.1.RELEASE。引入thymeleaf的方法是在pom.xml文件中引入:

[code]<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
<!-- 布局功能的支持程序  thymeleaf3主程序  layout2以上版本 -->
<!-- thymeleaf2   layout1-->
<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
</properties>
[code]<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

 

引入thymeleaf后启动springboot项目会报错。报错信息为:

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:/C:/CODE/maven-repository/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:/C:/CODE/maven-repository/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

百度没有得到解决,然后对比示例和本人的pom文件,发现唯一的不同是spring-boot-starter-parent的版本,于是将自己的spring-boot-starter-parent版本改为1.5.10.RELEASE问题得到解决。

由于时间不多,没有深究原因,在此做个记录,希望能在以后的时间里回头找出根本原因,同时有网友朋友们知道原因的话留个言以帮助到更多的人。

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: