I want to integrate Spring 4 with Thymeleaf, but I got:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name \'templateReso
Short
Replace ThymeleafViewResolver with SpringResourceTemplateResolver:
<bean
id="templateResolver"
class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver"
p:prefix="/WEB-INF/templates/"
p:suffix=".html"
p:templateMode="HTML5"
>
</bean>
Long
Few days ago I had the same problem when used Tutorial: Thymeleaf + Spring, it is
a bit outdated. Solution was found at "Thymeleaf 3 ten-minute migration guide":
The first difference with the Thymeleaf 2 configuration is that now the recommended template resolver for Spring applications is SpringResourceTemplateResolver
You will need to hook in your templateEngine
to the viewResolver
. Here's my working one:
<bean id="viewResolver" class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
<property name="order" value="1"/>
<property name="characterEncoding" value="UTF-8"/>
<property name="templateEngine" ref="templateEngine"/> <!-- THIS -->
</bean>
<bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
<property name="templateResolvers">
<set>
<ref bean="webTemplateResolver"/>
</set>
</property>
<property name="additionalDialects">
<set>
<bean class="org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect"/>
</set>
</property>
</bean>