0
我有一個Eclipse-Maven-Spring項目和一個applicationcontext.xml
它。這就是:org.xml.sax.SAXParseException ...對於元素'context:component-scan'沒有聲明可以找到
<?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)
有一個在後來的folloving <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>
有人能幫助我嗎?
嗨,我接着說:http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context- 3.1.xsd'但我仍然得到相同的錯誤。 – SzZ
...我已經有一個'xmlns:context =「http://www.springframework.org/schema/context」'元素。 – SzZ
@SzZ你是否也修復了安全問題? schemaLocation屬性應該是交替命名空間和模式,你問題中的例子是「beansNS beansSchema securitySchema」,即它缺少安全性NS。你是否肯定使用所有彈簧庫的3.1版本? –