Hi,
I was trying to use <context:component-scan> in my demo project and encounter an error.
I have searched the solutions on the Internet, but can't get satisfied answer.
The following two links are similar with my problems:
[1]http://forum.springsource.org/showthread.php?77633-schema-document-http-www-springframework-org-schema-beans-spring-context-3-0-xsd
[2]http://stackoverflow.com/questions/1729307/spring-schemalocation-fails-when-there-is-no-internet-connection
The first one's error message is almost same with me, however the reason is he made a copy/paste mistake in configure file. I checked my file and there is no such problem.
The second solution does solve my problem, but not perfectly. I will get correct result of my app when apply this
solution, but it's a solution for offline mode(without Internet connection). Moreover, there is still error information saying "Failed to read schema document 'http://www.springframework.org/schema/tool/spring-tool-3.0.xsd'"
My configure file is:
When I replace the "spring-context-3.0.xsd" with "spring-context-2.5.xsd", everything is OK.Code:<?xml version = "1.0" encoding = "UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> <context:component-scan base-package="com.springinaction.autodiscovery" /> </beans>
Also, I can view the content of both "spring-context-3.0.xsd" and "spring-context-2.5.xsd" from the Eclipse.
I want to know the reason of the problem and the strange phenomena.
Thank you in advance~
Here is the error I got:
Code:org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/context/spring-context-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) .... at com.springinaction.autodiscovery.Demo.main(Demo.java:9) Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 14 in XML document from class path resource [autodiscovery.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 com.springinaction.autodiscovery.Demo.main(Demo.java:9) Caused by: 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'. ... ... 14 more




Reply With Quote
, I'm currently reading this book.
