【问题标题】:Configuration problem:Spring NamespaceHandler for [http://www.springframework.org/schema/mvc]配置问题:Spring NamespaceHandler for [http://www.springframework.org/schema/mvc]
【发布时间】:2011-11-07 10:01:59
【问题描述】:

配置问题:找不到 XML 模式命名空间的 Spring NamespaceHandler [http://www.springframework.org/schema/mvc]。

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

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

【问题讨论】:

  • 你解决了吗?要放哪个 jar 版本?我也遇到了同样的问题。

标签: spring spring-mvc


【解决方案1】:

由于缺少spring-webmvc依赖会发生所以添加 spring-webmvc 对 pom.xml 的依赖(如果不使用,则添加 jars maven 或任何构建

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

【讨论】:

    【解决方案2】:

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

    1. 清理您的本地服务器(在我的例子中是 Tomcat)。
    2. 从服务器中移除项目资源并重新发布。
    3. Clean 再次构建您的项目并查看结果。

    我的问题已解决。

    【讨论】:

      【解决方案3】:

      你看过这个吗?

      maven shade plugin 或这个 maven shade plugin 2

      它解决了我寻找spring context xml's.a链接的问题

      【讨论】:

        【解决方案4】:

        @蒂乔

        您需要检查几件事:

        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 保存在 webapp 的 WEB_INF/lib/ 文件夹中(直接将它们放在该文件夹中,而不是放在 WEB-INF/lib/ 的子文件夹中)。只有这样您的网络服务器才知道它们。这就是博卓的意思。

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

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

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

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

        希望有帮助!

        【讨论】:

          【解决方案5】:

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

          【讨论】:

          • ya..i 已将该 jar 文件包含在项目类路径中,但仍然出现相同的错误。
          • 在项目中 - 是的,但是在运行时类路径中?
          • 有效!我在 pom.xml 中添加了&lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;,这个问题就消失了。
          猜你喜欢
          • 2019-05-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-05-25
          • 2012-01-21
          • 2013-11-01
          • 2011-11-03
          相关资源
          最近更新 更多