1. The Problem
This article will discuss the most common configuration problem in Spring - the namespace handler for one of Spring's namespaces was not found. In most cases it is due to a particular Spring jar not being configured on the classpath, let's list most of the possible missing configurations and resulting exceptions.
2. http://www.springframework.org/schema/security The
security namespace is probably the most widespread problem encountered in practice so far:
copy code
<?xml version="1.0" encoding="UTF-8" ?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http ://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1 .xsd
http://www.springframework.
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
</beans:beans> results in
the following exception: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security] Offending resource: class path resource [securityConfig.xml] The solution is very simple - configure the jar of spring-security-config In the classpath (eg: maven's pom.xml): <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>3.1.4.RELEASE</ version> </dependency>
Configure the correct namespace handler - in this case the SecurityNamespaceHandler on the classpath will resolve elements in the security namespace.
3. http://www.springframework.org/schema/aop
occurs when the aop namespace is used, and the corresponding spring jar is not configured on the classpath:
copy code
<beans
xmlns="http://www.springframework. org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
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">
</beans>
Causes the following exception:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem:
Unable to locate Spring NamespaceHandler for XML schema namespace
[http://www.springframework.org/schema/aop]
Offending resource: ServletContext resource [/ WEB-INF/webConfig.xml] The
solution is similar to problem 2, just configure the jar of spring-aop under calsspath:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.2.5.RELEASE</version> <
/dependency>
4. http://www.springframework.org/schema/tx using transaction namespaces
- a small but very useful namespace configuration: beans xmlns="http://www.springframework. org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
</beans>
复制代码
导致以下异常:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem:
Unable to locate Spring NamespaceHandler for XML schema namespace
[http://www.springframework.org/schema/tx]
Offending resource: class path resource [daoConfig.xml]
The solution is to configure the jar of the transaction to the classpath:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.2 .5.RELEASE</version>
</dependency>
5. http://www.springframework.org/schema/mvc
Below is spring's mvc namespace
Copy code
<beans
xmlns="http://www.springframework.org /schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring- mvc-3.2.xsd">
</beans>
Copy code
results in the following exception:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem:
Unable to locate Spring NamespaceHandler for XML schema namespace
[http://www.springframework. org/schema/mvc]
Offending resource: class path resource [webConfig.xml]
encountered this exception because the spring mvc jar was not configured in the classpath:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
6. Conclusion
Finally , if you are using Eclipse to manage the web server and deployment, make sure that the assembly part of the deployment project is configured correctly - ie Maven dependencies, is actually included in the class classpath at deployment time.
Spring's namespace handler for a namespace not found
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326349897&siteId=291194637
Recommended
Ranking