我有一个Eclipse-Maven-Spring项目和一个applicationcontext.xml
。这是:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
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.1.xsd
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<description>SoapClient1</description>
<context:component-scan base-package="hu.bz.ikti.soap.test"/>
...
</beans>
解析xml时出现以下错误:
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 19 in XML document from class path resource [META-INF/spring/app-context1.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
在后面的<http>
xml 元素的开头有一个错误标志:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'http'. One of '{"http://
www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias,
"http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/
schema/beans"], "http://www.springframework.org/schema/beans":beans}' is expected.
在xsi:schemaLocation
我尝试添加的部分中,
http://www.springframework.org/schema/context/spring-context-3.2.xsd, spring-context-3.1.xsd, spring-context.xsd
但总是遇到相同的错误。
我有以下内容pom.xml
:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.framework.version}</version>
</dependency>
有人可以帮我吗?