java.lang.ClassNotFoundException:org.springframework.ui.ModelMap [英] java.lang.ClassNotFoundException: org.springframework.ui.ModelMap

查看:105
本文介绍了java.lang.ClassNotFoundException:org.springframework.ui.ModelMap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用tomcat 6,spring 2.5.6和maven创建了一个简单的webapp.

I create a simple webapp using tomcat 6, spring 2.5.6 and maven.

问题是当我启动tomcat时,出现以下错误:

The problem is when I boot up tomcat, I am getting the following errors:

SEVERE: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: org/springframework/ui/ModelMap
...
Caused by: java.lang.ClassNotFoundException: org.springframework.ui.ModelMap

ModelMap类确实存在于spring-2.5.6.jarspring-context-2.5.6.jar中,我也有一些其他的Spring jar.所有这些都正确地部署到了tomcat,当我检查应用程序WEB-INF(部署到tomcat)时,我在那里找到了所有的jars!

The ModelMap class does exist in spring-2.5.6.jar and spring-context-2.5.6.jar, I also have some other spring jars. All of them are being deployed to tomcat correctly, when I check the application WEB-INF (deployed to tomcat) I found all those jars there!

我只有一个具有@RequestMapping("/home.htm") showForm(ModelMap model)方法的@Controller. 我的applicationContext很简单:

I have only one @Controller that has a @RequestMapping("/home.htm") showForm(ModelMap model) method. My applicationContext is quite simple:

<?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>

推荐答案

spring-2.5.6.jar是包含所有Spring框架的JAR.如果使用该JAR,则不应使用任何其他JAR,例如spring-context-2.5.6.jar.如果您要挑选所需的Spring位数,可以使用这些较小的JAR.

spring-2.5.6.jar is the JAR that contains all of the spring framework. If you use that JAR, you should not use any of the other JARs like spring-context-2.5.6.jar. These smaller JARs are there if you want to pick ands choose the bits of Spring that you need.

在JAR之间的类的重复副本之间,类加载器可能会感到困惑.取出除spring-2.5.6.jar之外的所有Spring JAR,看看是否有区别.

It's possible that the classloader is getting confused between the duplicate copies of the classes between the JARs. Take out all of the Spring JARs except for spring-2.5.6.jar, and see if that makes a difference.

这篇关于java.lang.ClassNotFoundException:org.springframework.ui.ModelMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆