配置问题:Spring NamespaceHandler for [http://www.springframework.org/schema/mvc]

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7254061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 04:37:56  来源:igfitidea点击:

Configuration problem:Spring NamespaceHandler for [http://www.springframework.org/schema/mvc]

springspring-mvc

提问by Tijo K Varghese

Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/mvc].

配置问题:无法为 XML 架构命名空间 [http://www.springframework.org/schema/mvc] 找到 Spring NamespaceHandler。

can anyone tell why this error is happening? this is my configuration.

谁能告诉为什么会发生这个错误?这是我的配置。

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:context="http://www.springframework.org/schema/context"
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">

回答by m2p

@Tijo

@蒂乔

You need to check few things:

您需要检查几件事:

  1. Whether the Spring version you are using is 3.0. You are referring to spring-beans-3.0.xsd, spring-context-3.0.xsd and spring-mvc-3.0.xsd in your configuration, so you need to use Spring 3.0.* JARs.

  2. You may already have all the required JARs in the build path, most likely as "Referenced libraries" by adding external JARs to your build path. You also need to keep all the JARs in the webapp's WEB_INF/lib/ folder (put them in that folder directly, and not in a sub-folder of WEB-INF/lib/). Only then your web server knows about them. This is what Bozho means.

  3. This is more subtle. Make sure you do not have multiple Spring JAR versions in your WEB-INF/lib folder.

  1. 您使用的 Spring 版本是否为 3.0。您在配置中指的是 spring-beans-3.0.xsd、spring-context-3.0.xsd 和 spring-mvc-3.0.xsd,因此您需要使用 Spring 3.0.* JAR。

  2. 您可能已经在构建路径中拥有所有必需的 JAR,最有可能通过将外部 JAR 添加到您的构建路径来作为“参考库”。您还需要将所有 JAR 保存在 web 应用程序的 WEB_INF/lib/ 文件夹中(将它们直接放在该文件夹中,而不是放在 WEB-INF/lib/ 的子文件夹中)。只有这样,您的 Web 服务器才知道它们。这就是博佐的意思。

  3. 这更微妙。确保您的 WEB-INF/lib 文件夹中没有多个 Spring JAR 版本。

These are the same steps one needs to check for other NameSpaceHandler errors too, like

这些也是检查其他 NameSpaceHandler 错误所需的相同步骤,例如

Unable to locate Spring NamespaceHandler for XML schema namespace
http://www.springframework.org/schema/context

or

或者

Unable to locate Spring NamespaceHandler for XML schema namespace
[http://www.springframework.org/schema/security]

Hope that helps!

希望有帮助!

回答by Bozho

Spring needs a NamespaceHandleron the (runtime) classpath that can handle the mvc:namespace. This is the MvcNamespaceHandler, and it is located in the spring-webmvc-xx.jar. Put that on your classpath.

Spring 需要一个NamespaceHandler可以处理mvc:命名空间的(运行时)类路径。这是MvcNamespaceHandler,它位于spring-webmvc-xx.jar。把它放在你的类路径上。

回答by fredde

Have you had a look at this?

你看过这个吗?

maven shade pluginor this maven shade plugin 2

maven shade 插件或这个 maven shade 插件 2

It solved my problem with finding the spring context xml's.a link

它解决了我找到 spring 上下文 xml's.a 链接的问题

回答by Tejas Ghonge

I was getting same error while development on Eclipse. Some time it happens that required JAR is there at the correct location, but still this error message doesn't disappear. Don't Panic. First check if any of the above answers are working for you. If its not working follow below steps if you are facing this while development on Eclipse/STS.

我在 Eclipse 上开发时遇到同样的错误。有时,需要的 JAR 位于正确的位置,但此错误消息仍然没有消失。不要惊慌。首先检查上述任何答案是否适合您。如果它不起作用,如果您在 Eclipse/STS 上开发时遇到此问题,请按照以下步骤操作。

  1. Clean your Local Server (Tomcat in my case).
  2. Remove project resource from server and Republish it.
  3. Clean Build your project again and see the result.
  1. 清理你的本地服务器(在我的例子中是 Tomcat)。
  2. 从服务器中删除项目资源并重新发布。
  3. Clean 再次构建您的项目并查看结果。

Issue resolved in my case.

在我的情况下解决了问题。

回答by RamBen

due to lack of spring-webmvc dependency It will happen so add the spring-webmvc dependency to pom.xml (or add the jars if not using maven or any build

由于缺少 spring-webmvc 依赖,所以将 spring-webmvc 依赖添加到 pom.xml(如果不使用 maven 或任何构建,则添加 jars)

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>