springBoot+thyemleaf 启动项目出错

pom引入如下

<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>
  <dependencies>
 <!-- 引入thymeleaf -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
</dependencies>

错误信息如下

2019-09-04 07:36:05.271 ERROR 8088 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Failed to destroy the filter named [Tomcat WebSocket (JSR356) Filter] of type [org.apache.tomcat.websocket.server.WsFilter]

java.lang.AbstractMethodError: null
	at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:301) ~[tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4562) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5385) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1400) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1389) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_40]
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_40]
	at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:976) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1400) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1389) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_40]
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) [na:1.8.0_40]
	at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:976) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:473) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:994) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:257) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.apache.catalina.startup.Tomcat.stop(Tomcat.java:466) [tomcat-embed-core-9.0.22.jar:9.0.22]
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stopTomcat(TomcatWebServer.java:254) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stop(TomcatWebServer.java:309) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.stopAndReleaseWebServer(ServletWebServerApplicationContext.java:306) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203) [spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at com.springboot.springbootdruc.SpringBootDrucApplication.main(SpringBootDrucApplication.java:10) [classes/:na]

2019-09-04 07:36:05.283  INFO 8088 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-04 07:36:05.289 ERROR 8088 --- [           main] 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:154)

==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/Administrator/.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/Administrator/.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

主要原因

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/Administrator/.m2/repository/org/thymeleaf/thymeleaf-spring5/3.0.9.RELEASE/thymeleaf-spring5-3.0.9.RELEASE.jar!/org/thymeleaf/spring5/SpringTemplateEngine.class

因为当前thymeleaf版本为<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>已经不适用导致

解决方法

将<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>改为
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: springboot+thymeleaf项目是一种基于Java语言开发的Web应用程序。它采用了Spring Boot框架和Thymeleaf模板引擎,可以快速地搭建一个高效、可靠、易于维护的Web应用程序。该项目具有以下特点: 1. 简单易用:Spring Boot框架提供了一系列的自动化配置,使得开发者可以快速地搭建一个Web应用程序,而不需要过多的配置。 2. 高效可靠:Spring Boot框架采用了一系列的优化措施,使得应用程序具有高效、可靠的性能。 3. 易于维护:Thymeleaf模板引擎提供了一种简单、易于维护的模板语言,使得开发者可以快速地开发出具有良好可读性的Web应用程序。 总之,springboot+thymeleaf项目是一种非常优秀的Web应用程序开发框架,可以帮助开发者快速地开发出高效、可靠、易于维护的Web应用程序。 ### 回答2: Spring Boot是一个基于Spring框架的快速开发框架,这个框架的优点在于其简单易用,能够快速搭建一个Java Web应用程序,无需进行复杂的配置和繁琐的XML文件编写。而Thymeleaf则是一种Web和HTML的模板引擎,可以方便地处理文本、链接和表单等元素,支持多重继承和页面片段的复用等特性。 Spring Boot和Thymeleaf的结合,可以帮助开发人员更加简便地搭建Web应用程序。在使用Spring Boot进行项目开发时,可以使用Thymeleaf来完成Web开发的视图层,进行模版板的渲染和数据绑定。这样就可以很直接地将数据通过模板引擎展现出来,且更加方便。 在一个Spring Boot Thymeleaf项目的构建中,需要进行如下步骤: 1. 首先,引入Spring Boot和Thymeleaf的依赖以及其他必要的依赖,例如web和mybatis等相关组件。 2. 创建一个Controller类,并使用@Controller注解将类标记为Controller,编写具体的Action方法,这些方法可以用@RequestMapping或@GetMapping等注解来定义处理请求的URL路径和请求类型等相关信息。 3. 创建一个Model类,用于封装需要传输到前端的数据和相关操作等。 4. 在Controller内部设置Model变量并将相关数据注入Model,然后将需要展现的数据作为参数传递给Thymeleaf进行渲染,最后将渲染完成后的结果返回给前端页面展现。 5. 编写HTML页面,使用Thymeleaf标签来渲染动态数据。 需要注意的是,在进行Thymeleaf模板的渲染时,需要遵守一定的规范,例如页面中的数据变量名称需与Model中的属性名称一致,引入Thymeleaf命名空间等等。 总之,Spring Boot与Thymeleaf结合使用可以帮助开发人员快速地完成Web开发,整个过程简单而且高效。使用Thymeleaf能够降低模版制作的门槛,进一步提高开发效率,并且能够提供丰富的模版处理标签,使得页面制作更加灵活。 ### 回答3: 近年来,使用SpringBoot和Thymeleaf进行Web开发已经成为越来越多的开发者选择的方案。SpringBoot是一个基于Spring框架的快速Web应用开发框架,而Thymeleaf是一种基于HTML的模板引擎,其中需要了解的内容包括以下几点: 首先,SpringBoot框架的优点是非常明显的。它提供了很多便于使用的方法,例如自动装配,以及基于配置的许多默认值。这使得开发者可以花更少的时间和精力来开发项目,将重点放在业务逻辑和功能实现上。 其次,Thymeleaf是一种非常强大和灵活的模板引擎,其语法简单易懂,而且支持HTML5标准。它还提供了一些样式和布局的工具,以及易于使用的表达式和标签,使得Web页面开发更加容易。 当然,SpringBoot集成Thymeleaf的过程也并不复杂。只需添加thymeleaf-starter包依赖,SpringBoot将自动将Thymeleaf注册为默认的模板引擎。然后,您只需要编写Thymeleaf模板文件即可。 最后,值得注意的是,使用SpringBoot和Thymeleaf进行Web开发的好处在于它们之间的紧密集成。这种紧密集成可以更轻松地创建动态和交互性的Web应用程序,这是传统的HTML和JavaScript不能提供的。 总的来说,SpringBoot和Thymeleaf是一对非常强大且易于使用的Web开发工具组合,它们的出现大大提高了Web开发的效率和质量,同时也为开发人员提供了更好的开发体验。我们相信,这对于Web开发者来说是非常有价值的组合。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值