我正在使用Spring 3.2.3.RELEASE与Maven拉取依赖项。在Eclipse中构建项目时,我遇到以下错误:
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'.
我的application-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依赖项显示如下:
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
我也查看了以下内容,但没有发现任何解决方案: 无法加载Spring 3 schemas 'tx:annotation-driven'元素的匹配通配符很严格,但找不到声明 'context:component-scan'元素找不到声明 'context:component-scan'元素的匹配通配符很严格,但找不到声明 请帮忙解决问题,这真的把我逼疯了.... :(
/
。 - Nicolas Zozol