2013-11-03 98 views
9

我是Spring的新手,我想使用Velocity進行設置。因此,我在Eclipse Kepler中使用Spring Tool Suite Extension創建了一個新的Spring項目,一個新的Spring MVC項目。然後,我添加了org.apache.velocity到版本爲1.7的新的Spring Project。之後,我加入以下行我servlet-context.xml,根據http://docs.spring.io/spring/docs/3.2.x/javadoc-api/org/springframework/web/servlet/view/velocity/VelocityConfigurer.html在Spring Framework 3.2.4中使用Apache Velocity

<beans:bean id="velocityConfig" 
    class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> 
    <beans:property name="resourceLoaderPath" value="/WEB-INF/views/" /> 
</beans: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. --> 
<beans:bean id="viewResolver" 
    class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> 
    <beans:property name="cache" value="true" /> 
    <beans:property name="prefix" value="" /> 
    <beans:property name="suffix" value=".jsp" /> 
</beans:bean> 

然後一切都很好。但是,如果我改變springframework的版本在pom.xml從3.1.1.RELEASE到3.2.4.RELEASE,我得到在Eclipse中顯示以下錯誤:

No setter found for property 'resourceLoaderPath' in class 'org.springframework.web.servlet.view.velocity.VelocityConfigurer' 

我甚至設置好的了一個新的虛擬機與Ubuntu來測試它 - 我到處都有同樣的錯誤。你需要更多的文件嗎?

mvn依賴關係的輸出:樹在我看來並不可疑,是嗎?

[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building test 1.0.0-BUILD-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ c --- 
[INFO] a.b:c:war:1.0.0-BUILD-SNAPSHOT 
[INFO] +- org.springframework:spring-context:jar:3.2.4.RELEASE:compile 
[INFO] | +- org.springframework:spring-aop:jar:3.2.4.RELEASE:compile 
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile 
[INFO] | +- org.springframework:spring-beans:jar:3.2.4.RELEASE:compile 
[INFO] | +- org.springframework:spring-core:jar:3.2.4.RELEASE:compile 
[INFO] | \- org.springframework:spring-expression:jar:3.2.4.RELEASE:compile 
[INFO] +- org.springframework:spring-webmvc:jar:3.2.4.RELEASE:compile 
[INFO] | \- org.springframework:spring-web:jar:3.2.4.RELEASE:compile 
[INFO] +- org.aspectj:aspectjrt:jar:1.6.10:compile 
[INFO] +- org.slf4j:slf4j-api:jar:1.6.6:compile 
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.6:runtime 
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.6:runtime 
[INFO] +- log4j:log4j:jar:1.2.15:runtime 
[INFO] +- javax.inject:javax.inject:jar:1:compile 
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided 
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.1:provided 
[INFO] +- javax.servlet:jstl:jar:1.2:compile 
[INFO] +- junit:junit:jar:4.7:test 
[INFO] +- org.mockito:mockito-all:jar:1.9.5:compile 
[INFO] +- org.springframework:spring-test:jar:3.2.4.RELEASE:compile 
[INFO] \- org.apache.velocity:velocity:jar:1.7:compile 
[INFO] +- commons-collections:commons-collections:jar:3.2.1:compile 
[INFO] \- commons-lang:commons-lang:jar:2.4:compile 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1.764s 
[INFO] Finished at: Sun Nov 03 14:15:18 CET 2013 
[INFO] Final Memory: 12M/149M 
[INFO] ------------------------------------------------------------------------ 

如果我運行一個Tomcat服務器上的項目,我得到以下錯誤:

HTTP Status 500 - Servlet.init() for servlet appServlet threw exception 

type Exception report 

message Servlet.init() for servlet appServlet threw exception 

description The server encountered an internal error that prevented it from fulfilling this request. 

exception 

javax.servlet.ServletException: Servlet.init() for servlet appServlet threw exception 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) 
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) 
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) 
    java.lang.Thread.run(Thread.java:662) 
root cause 

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.velocity.VelocityConfigurer] for bean with name 'velocityConfig' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/ui/velocity/VelocityEngineFactory 
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.web.servlet.view.velocity.VelocityConfigurer] for bean with name 'velocityConfig' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/ui/velocity/VelocityEngineFactory 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) 
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) 
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) 
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) 
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) 
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665) 
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518) 
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459) 
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) 
    javax.servlet.GenericServlet.init(GenericServlet.java:160) 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) 
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) 
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) 
    java.lang.Thread.run(Thread.java:662) 
root cause 

org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.web.servlet.view.velocity.VelocityConfigurer] for bean with name 'velocityConfig' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/ui/velocity/VelocityEngineFactory 
    org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1278) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:575) 
    org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1344) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:355) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:334) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:321) 
    org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1174) 
    org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:102) 
    org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:88) 
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:163) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) 
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) 
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) 
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) 
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) 
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665) 
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518) 
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459) 
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) 
    javax.servlet.GenericServlet.init(GenericServlet.java:160) 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) 
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) 
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) 
    java.lang.Thread.run(Thread.java:662) 
root cause 

java.lang.NoClassDefFoundError: org/springframework/ui/velocity/VelocityEngineFactory 
    java.lang.ClassLoader.defineClass1(Native Method) 
    java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) 
    java.lang.ClassLoader.defineClass(ClassLoader.java:615) 
    java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) 
    org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2918) 
    org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1174) 
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1669) 
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) 
    org.springframework.util.ClassUtils.forName(ClassUtils.java:260) 
    org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:416) 
    org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1296) 
    org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1267) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:575) 
    org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1344) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:355) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:334) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:321) 
    org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1174) 
    org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:102) 
    org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:88) 
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:163) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) 
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) 
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) 
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) 
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) 
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665) 
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518) 
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459) 
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) 
    javax.servlet.GenericServlet.init(GenericServlet.java:160) 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) 
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) 
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) 
    java.lang.Thread.run(Thread.java:662) 
root cause 

java.lang.ClassNotFoundException: org.springframework.ui.velocity.VelocityEngineFactory 
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702) 
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) 
    java.lang.ClassLoader.defineClass1(Native Method) 
    java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) 
    java.lang.ClassLoader.defineClass(ClassLoader.java:615) 
    java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) 
    org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2918) 
    org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1174) 
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1669) 
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) 
    org.springframework.util.ClassUtils.forName(ClassUtils.java:260) 
    org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:416) 
    org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1296) 
    org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1267) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:575) 
    org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1344) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:355) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:334) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:321) 
    org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1174) 
    org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:102) 
    org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:88) 
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:163) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521) 
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) 
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) 
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) 
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) 
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) 
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) 
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) 
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599) 
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665) 
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518) 
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459) 
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) 
    javax.servlet.GenericServlet.init(GenericServlet.java:160) 
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) 
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) 
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) 
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) 
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) 
    java.lang.Thread.run(Thread.java:662) 
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.47 logs. 

Apache Tomcat/7.0.47 
+0

幾個祕訣。嘗試在eclipse之外運行「mvn」來查看它是依賴性問題還是eclipse。另外,從命令行運行「mvn dependency:tree」,並檢查獲取的依賴關係的版本。 –

+0

我已經將輸出添加到我的問題 - 它看起來對我來說是好的...因爲我可以在tomcat服務器上運行它不認爲這是一個日食問題? – Ragadabing

回答

20

這是現在顯然是一個類路徑的問題。

java.lang.NoClassDefFoundError: org/springframework/ui/velocity/VelocityEngineFactory 
java.lang.ClassNotFoundException: org.springframework.ui.velocity.VelocityEngineFactory 

你缺少spring-context-support罐子其中包含VelocityEngineFactory類。

添加這種依賴性

<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-context-support</artifactId> 
    <version>${spring.version}</version> 
</dependency> 
+1

謝謝,謝謝,謝謝!你不知道我現在有多快樂,也不知道我花了多少時間試圖自己解決這個問題。你太棒了!!! – Ragadabing

+5

@Paloran這裏有一個技巧,如果你還不知道,在Eclipse中,按下'CTRL + SHIFT + T'並寫下類的名字。如果它沒有找到它,那麼它從你的項目的類路徑中缺失。如果它找到了它,在Project Explorer中,你可以點擊'Link with Editor'箭頭按鈕來查看它實際在哪個jar中。 –