0
我想從Thymeleaf 2.1.3遷移到3.0.8。我更新了pom.xml文件,就像您可以在下面看到的最新版本的資源一樣。如果我嘗試將戰爭文件部署到Jboss,我得到一個BeanCreationException。詳細的Stacktrace你可以在下面找到。Thymeleaf從2遷移到3使用thymeleaf-extras-conditionalcomments獲得例外
我猜這個異常是由於在ConditionalCommentsDialect的超類構造函數中缺少了屬性而引發的。 ConditionalCommentsDialect擴展了org.thymeleaf.dialect.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>
彈簧配置文件
<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
看起來像是類路徑中不同版本庫的混合。 –