schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-2.5.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>.
One solution: Cut and paste the code and save it.
Sometimes you will find that a system that has been booting up properly in the past will one day report the following error:
(plain)
view plain
The copy
- org. XML, sax SAXParseException: schema_reference. 4: Failed to read the schema document ‘http://www.springframework.org/schema/beans/spring-beans-2.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> . ol>
Obviously, the XSD file specified in the Spring XML configuration file cannot be read, mostly due to an outage or the temporary inability to connect to the Spring official website. You can use the browser type XSD file URL, such as: http://www.springframework.org/schema/beans/spring-beans-2.0.xsd for confirmation.
There are two common online solutions to this problem. The first is simple and effective, but cumbersome: convert all spring configuration files with XSD paths in the form of urls to paths in the form of CLASspath pointing to local XSD files, for example: Classpath: org/springframework/beans/factory/XML/spring beans – 2.5 XSD, another way is to build in the native web server, according to the URL to create the corresponding folder, in a corresponding XSD file, add “127.0.0.1 www.springframework.org” in the machine hosts file. In fact, both of these approaches are “skew” approaches, and to figure this out you need to start with Spring’s XSD file loading mechanism.
First of all: You must know that Spring always tries to look up the XSD file locally when it loads the XSD file (all versions of the XSD file are already included in the Spring JAR), and if it is not found, then it will go to the URL specified path to download. This is a perfectly reasonable thing to do, and it doesn’t look like it’s downloaded from the site every time. In fact, if all of your configurations are positive, your project can be started without an error if the network is disconnected. Spring load XSD file class is PluggableSchemaResolver, you can take a look at its source to verify the above statement. In addition, you can add in log4j.xml:
[HTML]
view plain
The copy
- < The logger name = “org. Springframework. Beans. Factory. XML” & gt; & lt; Level value = “all”/& gt; & lt; /logger> ol>
Log to see how Spring loads XSD files.
Next, the question is why Spring didn’t find the required files locally and had to go to the web site to download them. And this is a very simple question. In many Spring JARS, under the meta-INf directory, there is a Spring.schemas, this is a property file, the contents of which are like the following:
(plain)
view plain
The copy
The
- http\://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd http\://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/ Springframework/beans/factory/XML/spring beans – 2.5 XSD http\://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd… ol>
In fact, this file is spring’s mapping of the local location path of the XSD file that Spring USES to find the XSD file locally (that is, in spring’s JAR). The reason for not finding the XSD file may be that the version of the declared XSD file does not exist locally, other than the URL typing error. In general, the new version of the spring jar package will all the past version (2.0) should be self XSD packaging, and in the spring. The schema file to add the corresponding item, the situation of the problems are often the statement USES a high version of the XSD file, such as 3.0, but rely on the spring jar package is the previous version 2.5, due to the nature not may contain 3.0 2.5 XSD file, at this time will cause the spring to XSD file target site to download, in case of broken network or target site is not available, That’s what happened.
However, in implementation development, these errors are not uncommon, and the most common cause of this problem is related to the use of a Maven packaging plug-in called “Assembly.” Many projects need to package the project together with all the JARS it depends on into a jar package, and Maven’s Assembly plug-in is designed to do this. But because the engineering often rely on many jars, and be dependent jar can rely on other jar package, so that when the project rely on to a different version of the spring, when using the assembly for packaging, can only be one version under the jars of spring. The schemas files into finally hit the jar of the bag, it’s likely missing out on some version of the XSD local map, then the article mentioned at the beginning of the error. If your project is a single JAR, you can verify that this is not the case by examining the Spring.schemas file in the resulting JAR. In this case, the solution is generally recommended to use another packaged plug-in shade, which is indeed a more excellent tool than assembly. On the processing of Spring.schemas file, shade can merge all the Spring.schemas files in all jars.
This is the mechanism by which Spring loads XSD files and the analysis of the cause of the problem. In fact, we should have our project always load a native XSD file at startup, rather than download it every time we go to the site, which requires a review of your project in the context of the above.
In this paper, the original link: http://blog.csdn.net/bluishglc/article/details/7596118, reprint please indicate the source!
Through baidu and search, I found that it was caused by the mismatch between the version and configuration of spring That I relied on in Maven POM.xml.
I used
< in the pom.xml; spring.version> 4.0.9. RELEASE< /spring.version>
USES version 4.0, but the above is version 3.1
. Change the spring configuration in the above screenshot to 4.0, and do a clean operation at the same time, the problem is solved
Read More:
- Unable to read Scheme Document ‘ http://www.springframework.org/schema/beans/spring-beans-4.1.xsd ‘ [How to Fix]
- Unable to read scheme document‘ http://www.springframework.org/schema/spring-context.xsd The solution to the problem
- “Hive metadata problem” hive.metastore.HiveMetaException : Failed to get schema version.
- Problem solving of failed to read candidate component class in Java
- JS error: permission denied to access property ‘document’— document.domain -The same source strategy of JavaScript
- Content rendering error: a solution to the problem of zero Download document cannot be opened
- Schema validation error in conig/config.xml. See the log for detais, Schema validation can be……
- Spring boot problem 1: error reporting life processing instructions for building a spring boot project
- Spring cloud config does not read bootstrap.properties/yml
- Spring initializer error: initialization failed for ‘ https://start.spring.io ‘
- When idea generates a spring boot project, error: read timed out appears
- The spring boot project was first created, pom.xml The error is Maven configuration problem. How to solve it?
- Spring configuration transaction, JUnit unit test error “failed to load ApplicationContext”
- Failed to instantiate org.mybatis.spring.SqlSessionTemplate Constructor threw exception
- Spring failed to commit the transaction
- In vs2013, reshharper and team management plug-in git share a temporary solution to the “failed modify to document” error.
- How to Fix Spring Boot OTS parsing error: Failed to convert WOFF 2.0
- Schema validation failed with the following errors: data path “. Budgets [1]. Type” should be
- VS2008 comes with crystal reports: Failed to Save Document
- Solution to the problem of spring boot running test class error creating bean with name ‘serverendpoint exporter’ defined