[英]Spring 3.0: Unable to locate Spring NamespaceHandler for XML schema namespace
[英]Spring 3.0 — Unable to locate Spring NamespaceHandler for XML schema namespace context
無法找到XML架構命名空間的Spring NamespaceHandler [ http://www.springframework.org/schema/context]
SEVERE: Exception sending context initialized event to listener instance of
class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unable to locate NamespaceHandler for namespace
[http://www.springframework.org/schema/context]
Offending resource: ServletContext resource [/WEB-INF/HelloWorld-service.xml]
這是我的HelloWorld-service.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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
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/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd"
default-autowire="byName">
<context:component-scan base-package="com.test.service">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Service"/>
</context:component-scan>
在我的pom.xml中,我有:
<properties>
<spring.version>3.0.5.RELEASE</spring.version>
</properties>
........
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
項目樹結構:
任何想法可能是什么原因?
通常,當我在eclipse下啟動WebApp時會發生這種情況; 我不知道為什么,似乎Eclipse找不到包含spring XSD架構的spring jar通常我通過在WEB-INF / lib目錄下添加spring jar來解決它(通過使用在pom.xml中聲明的相同名稱)
如果您正在使用eclipse,請嘗試以下步驟:
右鍵單擊project-> properties-> Deployment Assembly-> Java build path entries-> Maven dependencies
這意味着在部署程序集中添加maven依賴項
我在項目的POM中使用彈簧BOM(“物料清單”)取得了成功:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>3.2.6.RELEASE</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
但是maven中央存儲庫中最早版本的spring-framework-bom是3.2.6.RELEASE ,你必須遷移到另一個版本才能使用BOM。 BOM確保按版本一致地分辨工件。 這也允許您從依賴項中刪除所有<version>${spring.version}</version>
。
和“無版本”xsd參考:
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.