【发布时间】:2015-10-21 14:50:49
【问题描述】:
thymeleaf 是新的,并试图将其集成到 spring mvc 4 中。
按照this教程我遇到了这个问题:
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.thymeleaf.templateresolver.ServletContextTemplateResolver]for bean with name 'templateResolver' defined in ServletContext resource [/WEB-INF/spring-mvc-config.xml];
现在我确定您拥有所有必要的罐子,这取决于什么? 附上配置文件。
spring-mvc-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="it.shakesoft.common.controller" />
<bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML5" />
</bean>
<bean id="templateEngine"
class="org.thymeleaf.spring4.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolver" />
</bean>
<bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" />
</bean>
</beans>
【问题讨论】:
-
你能发布你的pom吗?看起来它缺少 spring4 defn - mvnrepository.com/artifact/org.thymeleaf/thymeleaf-spring4
-
我不使用 maven,我在类路径中手动添加 thymeleaf-sping4-2.1.4 jar
-
你能确认类路径吗?它没有找到罐子
-
我确认类路径...
标签: java spring-mvc thymeleaf