我使用 tomcat 6、spring 2.5.6 和 maven 创建了一个简单的 webapp。
问题是当我启动tomcat时,我收到以下错误:
SEVERE: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: org/springframework/ui/ModelMap
...
Caused by: java.lang.ClassNotFoundException: org.springframework.ui.ModelMap
ModelMap 类确实存在于spring-2.5.6.jar
and中spring-context-2.5.6.jar
,我还有一些其他的 spring jars。所有这些都正确部署到tomcat,当我检查应用程序WEB-INF(部署到tomcat)时,我在那里找到了所有这些jar!
我只有一个有@RequestMapping("/home.htm") showForm(ModelMap model)
方法的@Controller。我的 applicationContext 很简单:
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd"
default-autowire="byName">
<context:component-scan base-package="org.myapp"/>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
<property name="prefix" value="/WEB-INF/view/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>