具有Freemarker的ClassNotFoundException [英] ClassNotFoundException with Freemarker
问题描述
对不起我的问题,但我无法解决.
sorry for my noobie question, but I can't figure it out.
我有一个使用Spring MVC在GAE上运行的应用程序,我正在尝试添加Free Marker作为模板语言.
I have an application running on GAE, with Spring MVC and I am trying to add Free Marker as templating language.
在我的pom.xml中,我有:
In my pom.xml, I have:
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.20</version>
</dependency>
此外,在我的调度程序配置中,我已经配置了freemarker视图解析器,如下所示:
Also, in my dispatcher config, I have configured freemarker view resolver like this:
<!-- freemarker config -->
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/views/" />
</bean>
<!-- View resolvers can also be configured with ResourceBundles or XML files.
If you need different view resolving based on Locale, you have to use the
resource bundle resolver. -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="cache" value="true" />
<property name="prefix" value="" />
<property name="suffix" value=".ftl" />
</bean>
当我使用Eclipse启动Web服务器时,我收到一个classnotfound异常(请参见下文),但是我无法弄清缺少的内容以及如何添加它=(
When I start the webserver with Eclipse, I get a classnotfound exception (see below), but I cannot figure out what's missing and how to add it =(
你能帮我吗?
谢谢!
2013-11-07 17:30:17.097:WARN::Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer] for bean with name 'freemarkerConfig' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: problem with class file or dependent class; nested exception is
java.lang.NoClassDefFoundError: org/springframework/ui/freemarker/FreeMarkerConfigurationFactory|Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer] for bean with name 'freemarkerConfig' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/ui/freemarker/FreeMarkerConfigurationFactory:
java.lang.ClassNotFoundException: org.springframework.ui.freemarker.FreeMarkerConfigurationFactory
推荐答案
您必须将spring-context-support
添加到您的项目中.将此添加到您的pom.xml:
You have to add the spring-context-support
to your project. Add this to your pom.xml:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
这篇关于具有Freemarker的ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!