Spring mvc Thymeleaf从2迁移到3使用Thymeleaf附加条件注释获得异常

Spring mvc Thymeleaf从2迁移到3使用Thymeleaf附加条件注释获得异常,spring-mvc,thymeleaf,Spring Mvc,Thymeleaf,我想从Thymeleaf 2.1.3迁移到3.0.8。我用最新版本的Resources更新了pom.xml文件,如下所示。如果我尝试将war文件部署到Jboss,我会得到一个BeanCreationException。您可以在下面找到详细的Stacktrace 我猜引发异常的原因是ConditionalCommentsDialect的超类构造函数中缺少属性。ConditionalCommonsDialect正在扩展org.thymeleaf.dial.AbstractDialect,并且在thy

我想从Thymeleaf 2.1.3迁移到3.0.8。我用最新版本的Resources更新了pom.xml文件,如下所示。如果我尝试将war文件部署到Jboss,我会得到一个BeanCreationException。您可以在下面找到详细的Stacktrace

我猜引发异常的原因是ConditionalCommentsDialect的超类构造函数中缺少属性。ConditionalCommonsDialect正在扩展org.thymeleaf.dial.AbstractDialect,并且在thymeleaf 3版本中更改了构造函数。似乎ConditionalCommentsDialect与Thymeleaf 3不兼容。那么我的假设正确吗?有什么办法解决这个问题吗?提前谢谢

pom.xml

<dependency>
  <groupId>org.thymeleaf</groupId>
  <artifactId>thymeleaf</artifactId>
  <version>3.0.8.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.thymeleaf</groupId>
  <artifactId>thymeleaf-spring4</artifactId>
  <version>3.0.8.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.thymeleaf</groupId>
  <artifactId>thymeleaf-testing</artifactId>
  <version>3.0.3.RELEASE</version>
  <scope>test</scope>
</dependency>

<dependency>
  <groupId>org.attoparser</groupId>
  <artifactId>attoparser</artifactId>
  <version>2.0.4.RELEASE</version>
</dependency>

<dependency>
  <groupId>org.thymeleaf.extras</groupId>
  <artifactId>thymeleaf-extras-conditionalcomments</artifactId>
  <version>2.1.2.RELEASE</version>
</dependency>

<dependency>
  <groupId>nz.net.ultraq.thymeleaf</groupId>
  <artifactId>thymeleaf-layout-dialect</artifactId>
  <version>2.2.2</version>
</dependency>

org.thymeleaf
百里香
3.0.8.1发布
org.thymeleaf
百里香
3.0.8.1发布
org.thymeleaf
胸腺素试验
3.0.3.1发布
测试
org.attoparser
阿拓分析器
2.0.4.1发布
org.thymeleaf.extras
百里香附加条件说明
2.1.2.1发布
nz.net.ultraq.thymeleaf
百里香方言
2.2.2
spring配置文件

<util:set id="extraDialects">
  <bean class="nz.net.ultraq.thymeleaf.LayoutDialect"/>
  <bean class="org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect"/>
</util:set>

<bean id="templateResolver"
      class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver"
      p:prefix="classpath:/views/" p:suffix=".html"
      p:templateMode="HTML5" p:characterEncoding="UTF-8"/>

<bean id="templateEngine"
      class="org.thymeleaf.spring4.SpringTemplateEngine"
      p:templateResolver-ref="templateResolver"
      p:extraDialects-ref="extraDialects"/>

<bean id="viewResolver"
      class="org.thymeleaf.spring4.view.ThymeleafViewResolver"
      p:templateEngine-ref="templateEngine"
      p:characterEncoding="UTF-8"/>

例外情况

Error creating bean with name 'extraDialects': Cannot create inner bean org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect#503d1586' of type [org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect] while setting bean property 'sourceSet' with key [1];
    nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect#503d1586' defined in class path resource [spring-webmvc.xml]: Instantiation of bean failed;
    nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect]: Constructor threw exception;
    nested exception is java.lang.NoSuchMethodError: org.thymeleaf.dialect.AbstractDialect: method <init>()V not found
创建名为“Extradialents”的bean时出错:在使用键[1]设置bean属性“sourceSet”时,无法创建[org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect]类型为[org.thymeleaf.extras.ConditionalCommentsDialect]的内部bean org.thymeleaf.extras.ConditionalCommentsDialect.ConditionalCommentsDialect.ConditionalCommentsDialect;
嵌套异常为org.springframework.beans.factory.beancreatitionException:创建名为“org.thymeleaf.extras.conditionalcomments.dial.ConditionalCommentsDialect”的bean时出错,该bean的实例化失败;
嵌套异常为org.springframework.beans.BeanInstantiationException:未能实例化[org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect]:构造函数引发异常;
嵌套异常为java.lang.NoSuchMethodError:org.thymeleaf.dialen.AbstractDialent:method()未找到

条件注释现在作为Thymeleaf核心的一部分提供(自版本3起)。您可以简单地删除该依赖项。

看起来像是类路径中具有不同版本的库的混合。