Configuration problem:Spring NamespaceHandler for

2020-06-03 07:25发布

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

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

5条回答
何必那么认真
2楼-- · 2020-06-03 07:41

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

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>
查看更多
地球回转人心会变
3楼-- · 2020-06-03 07:46

@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.

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

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!

查看更多
SAY GOODBYE
4楼-- · 2020-06-03 07:51

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.

  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.

Issue resolved in my case.

查看更多
Emotional °昔
5楼-- · 2020-06-03 07:54

Spring needs a NamespaceHandler on 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.

查看更多
对你真心纯属浪费
6楼-- · 2020-06-03 08:02

Have you had a look at this?

maven shade plugin or this maven shade plugin 2

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

查看更多
登录 后发表回答