Could not read schema document 'http://www.springframework.org/schema/beans/spring-beans-4.1.xsd' problem solving

Cause:
I was happily debugging the project one minute ago, but the following exception was thrown suddenly when the project was started the next second, and the project failed to start, first look at the error message:

无法读取方案文档 'http://www.springframework.org/schema/beans/spring-beans-4.1.xsd', 
原因为 1) 无法找到文档; 2) 无法读取文档; 3) 文档的根元素不是 <xsd:schema>

If there is a problem, of course, Baidu and Google first. The reason is that the spring official website sometimes cramps and cannot be accessed or your network is very poor . http://www.springframework.org/schema/beans/spring-beans- 4.1.xsd is the address. In short, if you can't open this link address, your project will be shit.

Nani! How can you be so controlled by people? So I started searching for a solution, and finally found a reliable way to let the project load the local spring-beans-xxxsd file to get rid of the restrictions on network requests. First look at the details of the local configuration file:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:context="http://www.springframework.org/schema/context" xmlns:jms="http://www.springframework.org/schema/jms" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd

My local solution was to replace http://www.springframework.org/schema/beans/spring-beans-4.1.xsd with classpath:/org/springframework/beans/factory/xml/spring-beans-2.0.xsd of course You will ask why you replace it with the spring-beans-2.0.xsd version instead of another version. In the development tool (I use idea), use ctrl + left click to select http://www.springframework.org/schema/ beans/spring-beans-4.1.xsd jump to the file is classpath:/org/springframework/beans/factory/xml/spring-beans-2.0.xsd I have not tried other versions of xsd, interested students can try Next; after the replacement is completed, the annoying error message will no longer appear when you start directly, and you can happily debug the project again.

The 0927 project is over: Looking back at the content written above, I feel that I was really stupid at the time. The problem with the above method is that batch changes are troublesome, and classpath syntax errors will be reported.
In fact, if you look at the log information carefully at that time, there will be no above practice;

Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/beans/spring-beans-3.2.xsd]
Found XML schema [http://www.springframework.org/schema/beans/spring-beans-3.2.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-3.2.xsd
Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/context/spring-context-3.2.xsd]
Found XML schema [http://www.springframework.org/schema/context/spring-context-3.2.xsd] in classpath: org/springframework/context/config/spring-context-3.2.xsd
Trying to resolve XML entity with public id [null] and system id [http://www.springframework.org/schema/tool/spring-tool-3.2.xsd]
Found XML schema [http://www.springframework.org/schema/tool/spring-tool-3.2.xsd] in classpath: org/springframework/beans/factory/xml/spring-tool-3.2.xsd

The above is the project startup loading information, indicating that the local xsd file will be automatically loaded when the project is started. The above problem occurs because the file of the 4.1.xsd version I configured can only support the 3.2.xsd version file at the highest local speed. When the network speed is good Request to xsd file via http. However, when the network speed is not good, the high version of the xsd file cannot be supported locally, only an error message will be reported, and the project startup will fail.
From the above analysis, two solutions are obtained, one is to upgrade the jar package of the higher version which contains the higher version of the xsd file, and the other is to reduce the version of the xsd file of the configuration so that the local jar can be satisfied. The last sentence makes the local jar satisfy the configured xsd version and no exception message will appear.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325577492&siteId=291194637