Java 无法在Spring中自动连接RequestMappingHandleMapping

Java 无法在Spring中自动连接RequestMappingHandleMapping,java,spring,spring-mvc,swagger,Java,Spring,Spring Mvc,Swagger,我试图在使用SpringMVC框架创建的RESTAPI上启用Swagger。我试图使用自动生成json,但遇到了一个问题。根本原因似乎是swagger springmvc项目希望找到一个向Spring注册的RequestMappingHandlerMapping实例,但该bean不存在。启动服务器时,我遇到以下错误: No matching bean of type [org.springframework.web.servlet.mvc.method.annotation.RequestMap

我试图在使用SpringMVC框架创建的RESTAPI上启用Swagger。我试图使用自动生成json,但遇到了一个问题。根本原因似乎是swagger springmvc项目希望找到一个向Spring注册的RequestMappingHandlerMapping实例,但该bean不存在。启动服务器时,我遇到以下错误:

No matching bean of type [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]
我在项目的论坛上找到了。这里唯一与我相关的建议是将
添加到我的spring配置中,这是我目前没有的

但是,当我添加该行时,会出现以下错误:

org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:default-servlet-handler'.
我知道这通常是由于模式位置定义的问题,但这里的情况似乎不是这样。我在
mvc
前缀中使用了其他几个标记,因此我认为这一个应该失败是不对的。这是我的xml配置文件的头

<?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:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                    http://www.springframework.org/schema/context
                    http://www.springframework.org/schema/context/spring-context-3.0.xsd
                    http://www.springframework.org/schema/mvc
                    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    <mvc:annotation-driven/>

    <context:component-scan base-package="us.co.state.judicial.icces.webservices.rest" />

    <mvc:default-servlet-handler/>

    <bean name="serverUtil" class="us.co.state.judicial.icces.webservices.util.WebServerUtil" />

    <bean name="swaggerConfig" class="us.co.state.judicial.icces.webservices.config.SwaggerConfig" />

    ...(some extra beans to define internally accessible services chopped off)
</beans>

…(一些额外的bean用于定义内部可访问的服务)
所以我想,我的问题最终分为两部分: 1) 有人知道为什么
不适合我吗,或者有人知道为什么Swagger无法将
RequestMappingHandlerMapping的任何实例自动关联到我的项目中的另一个原因吗?如果有帮助的话,我很乐意发布关于我的配置的更多细节


您似乎正在使用一个较旧版本的Spring框架-您能确认您昨天使用的是Spring 3.2+–Biju Kunjummen吗


这一评论包含了答案。我犯了一个愚蠢的错误,非常感谢Biju的帮助。

请展示一下您的
。感谢您帮我查看@Dirk,我已经更新了我的原始问题,这样就不仅仅列出了配置文件的标题。您似乎使用的是较旧版本的Spring framework-您能确认您使用的是Spring 3.2+@BijuKunjummen吗?这不应该是问题,因为所需的xsd也包含在rev 3.0中:@BijuKunjummen是完全正确的对的我应该在这里发布之前阅读插件的完整文档,我的错误。我将结束这个问题。