我有一个使用FreeMarker的大型Web应用程序.当我最近更新到Spring 3.2.4并通过jetty或tomcat运行web应用程序时,我得到以下异常:java.lang.ClassNotFoundException:org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.
我知道Spring-webmvc中有FreeMarkerConfigurationFactory类,所以我的POM中包含依赖项.我不知道为什么我得到例外.我已经包含了我的POM和我的弹簧servlet.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>WhiteSwan-Web</artifactId>
<groupId>com.millad.whiteswan.web</groupId>
<version>1.5</version>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.12.v20130726</version>
</plugin>
</plugins>
</build>
<properties>
<org.springframework.version>3.2.4.RELEASE</org.springframework.version>
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
<junit.version>4.11</junit.version>
<joda.time.version>2.2</joda.time.version>
<mockito.version>1.9.5</mockito.version>
<freemarker.version>2.3.20</freemarker.version>
</properties>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-beta8</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-beta8</version>
</dependency>
<dependency>
<groupId>com.foursquare</groupId>
<artifactId>fongo</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.5</version>
</dependency>
<!-- …Run Code Online (Sandbox Code Playgroud) 我有一个Spring/JSF Web应用程序,它依赖于模块使用Freemarker模板.这是我为整合做的事情:
我将applicationContext-freemarker-module.xml导入applicationContext.xml我将配置bean添加到applicationContext-freemarker-module.xml,如下所示.
<bean id="freemarkerConfiguration" class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">
<property name="templateLoaderPath" value="classpath*:/"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
我把模板放到freemarker模块的src/main/resources目录下.我正在阅读如下模板:
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-freemarker-module.xml");
Configuration templateConfig = (Configuration) context.getBean("freemarkerConfiguration");
Template template = templateConfig.getTemplate("template.ftl");
Run Code Online (Sandbox Code Playgroud)
现在我为templateLoaderPath属性尝试了很多值,但我总是得到"找不到模板".例外.
Freemarker模块的JAR如下所示
template.ftl
applicationContext-freemarker-module.xml
com/.../ (classes)
META-INF
Run Code Online (Sandbox Code Playgroud)
我应该在哪里放模板文件,我应该为templateLoaderPath值设置什么?我无法理解为什么找不到"template.ftl".我试图设置正确的值数小时.我尝试了各种路径配置但没有成功.
非常感谢你的帮助,
对不起我的noobie问题,但我无法弄清楚.
我有一个运行在GAE上的应用程序,使用Spring MVC,我正在尝试添加Free Marker作为模板语言.
在我的pom.xml中,我有:
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.20</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
另外,在我的调度程序配置中,我已经配置了这样的freemarker视图解析器:
<!-- 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>
Run Code Online (Sandbox Code Playgroud)
当我使用Eclipse启动Web服务器时,我得到一个classnotfound异常(见下文),但我无法弄清楚缺少什么以及如何添加它=(
你能帮帮我吗?
谢谢!
2013-11-07 17:30:17.097:WARN::Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with …Run Code Online (Sandbox Code Playgroud)