匹配的通配符是严格的,但是对元素的上下文没有声明:component-scan'

问题描述:

我正在使用Spring 3.2.3.RELEASE用maven来拉取依赖关系。当建立在Eclipse项目我收到以下错误:匹配的通配符是严格的,但是对元素的上下文没有声明:component-scan'

Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 17 in XML document from class path resource [META-INF/spring/application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 64; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'. 

我器件的应用-context.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:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
    http://www.springframework.org/schema/context/ 
    http://www.springframework.org/schema/context/spring-context-3.2.xsd"> 

    <context:component-scan base-package="com.example" /> 

我知道我拉了正确的jar文件作为我的Maven依赖节目:

Eclipse Maven Dependencies

的META-INF/sping.schemas我可以看到我有正确的架构声明在我的罐内:

http\://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd 
http\://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd 
http\://www.springframework.org/schema/context/spring-context-3.1.xsd=org/springframework/context/config/spring-context-3.1.xsd 
http\://www.springframework.org/schema/context/spring-context-3.2.xsd=org/springframework/context/config/spring-context-3.2.xsd 
http\://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.2.xsd 

我也看了这些都无济于事:

Can't load spring 3 schemas

The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-driven'

No declaration can be found for element 'context:component-scan'

The matching wildcard is strict, but no declaration can be found for element 'context:component-scan

请帮帮忙,它的驾驶我疯了.. .. :(

对于初学者,您应该修复您的依赖关系。你在混合使用Spring 3.2.3和2.0.6 jar(这是等待发生的问题)。

旁边,你的声明是错的http://www.springframework.org/schema/context/必须是http://www.springframework.org/schema/context

+0

Ooo gosh thanks;甚至没有看到;除去最后的“/”这个技巧......将继续对这些依赖关系进行排序。 – Ithar

+0

相同的东西。我们必须在最后用'/'复制/粘贴相同的教程 –