SpringBoot使用thymleaf,加入版本控制和佈局版本控制的properties後報錯

背景:SpringBoot使用thymleaf在pom.xml文件中引入

<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.3.0</thymeleaf-layout-dialect.version>
</properties>

報錯內容:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-23 15:06:10.416 ERROR 15636 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration.templateEngine(ThymeleafAutoConfiguration.java:142)

The following method did not exist:

    org.thymeleaf.spring5.SpringTemplateEngine.setRenderHiddenMarkersBeforeCheckboxes(Z)V

The method's class, org.thymeleaf.spring5.SpringTemplateEngine, is available from the following locations:

    jar:file:/C:/Users/14195/.m2/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:/Users/14195/.m2/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


Process finished with exit code 0
 

 

 解析:創建項目的時候已經引入了thymleaf的模板引擎的依賴,再次個重複規定版本號導致出錯

解決:刪除<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>

提示:thymleaf的佈局版本一般比項目引入的thymleaf版本低一個版本

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章