找不到类:org.springframework.web.servlet.mvc.annotation。 DefaultAnnotationHandlerMapping

时间:2014-02-10 11:40:35

标签: spring classnotfound

我的调度程序-servlet文件是

<?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:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd 
                          http://www.springframework.org/schema/context 

http://www.springframework.org/schema/context/spring-context-3.2.xsd 
                          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd 
                          http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">




 <context:component-scan base-package="com.controller"/>


     <mvc:annotation-driven/>


    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping

" />

    <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>

    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />

运行应用程序后,我发现服务器日志中的错误是

class not found: "org.springframework.web.servlet.mvc.annotation. DefaultAnnotationHandlerMapping"

有人说我要添加适当的jar文件,但我已经添加了org.springframework.web.servlet-3.2.2.RELEASE.jar。

我添加了所有需要的jar。

1 个答案:

答案 0 :(得分:1)

尝试用以下方法替换你的bean类: org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping

也从xml中删除<mvc:annotation-driven/>

如果您已从spring 3.1.x升级到3.2.x

,则需要执行此操作