schema_reference.4:无法读取架构文档'http://www.springframework.org/schema/beans/spring- beans-4.1.5.xsd
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29063555/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring- beans-4.1.5.xsd
提问by Shamseer
I get an error in spring-dispatcher.xml in eclipse as given below.
我在 Eclipse 中的 spring-dispatcher.xml 中收到一个错误,如下所示。
schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-
beans-4.1.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>.
I have latest spring libraries...
我有最新的春季图书馆...
spring-beans-4.1.5.RELEASE.jar
spring-beans-4.1.5.RELEASE-javadoc.jar
spring-beans-4.1.5.RELEASE-sources.jar
spring-context-4.1.5.RELEASE.jar
spring-context-4.1.5.RELEASE-javadoc.jar
spring-context-4.1.5.RELEASE-sources.jar
spring-context-support-4.1.5.RELEASE.jar
spring-context-support-4.1.5.RELEASE-javadoc.jar
spring-context-support-4.1.5.RELEASE-sources.jar
spring-webmvc-4.1.5.RELEASE.jar
spring-webmvc-4.1.5.RELEASE-javadoc.jar
spring-webmvc-4.1.5.RELEASE-sources.jar
spring-webmvc-portlet-4.1.5.RELEASE.jar
spring-webmvc-portlet-4.1.5.RELEASE-javadoc.jar
spring-webmvc-portlet-4.1.5.RELEASE-sources.jar
spring-dispatcher.xml as given below...
spring-dispatcher.xml 如下所示...
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
It would be great if I get some help... The posts with same subject did not help me to resolve this.Thanks in advance...
如果我得到一些帮助,那就太好了...具有相同主题的帖子并没有帮助我解决这个问题。提前致谢...
回答by minion
The error is because it could not find the xsd. Try doing the below which is using a specific version 4.1.
错误是因为它找不到 xsd。尝试执行以下使用特定版本 4.1 的操作。
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
Or if you don't mention a version, it will try to use the latest.
或者,如果您不提及版本,它将尝试使用最新版本。
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
回答by Xelian
From Cosmina I. - Pivotal Certified Professional Spring Developer Exam A Study Guide - 2017
来自 Cosmina I. - Pivotal Certified Professional Spring Developer Exam A Study Guide - 2017
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
A recommended (best) practice is to use this, since the version will be correctly identified from the Spring dependency version in the project. Also, the other advantage is that you can upgrade the Spring version you are using, and the new definition specifications will be automatically supported in your configuration files without your having to modify them
推荐的(最佳)实践是使用它,因为将从项目中的 Spring 依赖版本正确识别版本。此外,另一个好处是您可以升级您正在使用的 Spring 版本,并且您的配置文件中将自动支持新的定义规范,而无需修改它们
回答by Tristan
There is no such xsd in any Spring jar : http://www.springframework.org/schema/beans/spring-beans-4.1.5.xsd
任何 Spring jar 中都没有这样的 xsd:http: //www.springframework.org/schema/beans/spring-beans-4.1.5.xsd
Spring xsd for Spring 4.1.x can be referenced by : http://www.springframework.org/schema/beans/spring-beans-4.1.xsdor better : http://www.springframework.org/schema/beans/spring-beans.xsd
Spring 4.1.x 的 Spring xsd 可以通过以下方式引用:http: //www.springframework.org/schema/beans/spring-beans-4.1.xsd或更好:http: //www.springframework.org/schema/beans/ spring-beans.xsd
The correspondance between the URL and the real location inside each spring jar can be found in META-INF/spring.schemas, so the "version less" URL will still work when u upgrade Spring.
URL和每个spring jar内部真实位置的对应关系可以在META-INF/spring.schemas中找到,所以升级Spring时“版本少”的URL仍然有效。
回答by Amit Kumar
In my case it went away by adding
在我的情况下,它通过添加消失了
<?xml version="1.0" encoding="utf-8"?>
to spring-dispatcher.xml and then running update maven project.
到 spring-dispatcher.xml 然后运行更新 maven 项目。
回答by Loa
Belive me or not, this may be a maven problem if you're using it and things ended up like this from nothing. I know this may not be your case, but if so, please update your maven project. If you're using Eclipse IDE:
信不信由你,如果你正在使用它,这可能是一个 Maven 问题,并且事情从无到有。我知道这可能不是您的情况,但如果是这样,请更新您的 Maven 项目。如果您使用的是 Eclipse IDE:
- Right click on the project name.
- Maven.
- Update Project...
- 右键单击项目名称。
- 马文。
- 更新项目...
Again, this maybe your case. It worked for me doing this. This can work also to anybody else who is on the same situation.
同样,这可能是您的情况。这样做对我有用。这也适用于处于相同情况的任何其他人。
回答by Anne Lingesh
Try this, it worked for me
试试这个,它对我有用
<beans xmlns = "http://www.springframework.org/schema/beans"
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-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
回答by Shafqat Shafi
I have enroled for spring course on udemy. I followed every step that my instructor show me to do. So if you are using spring mvc and hibernate you may encounter this error Failed to read schema document 'http://www.springframework.org/schema/tx/spring-tx.xsd' etc for:
我已经注册了 udemy 的春季课程。我按照老师教我做的每一步。因此,如果您使用 spring mvc 和 hibernate,您可能会遇到此错误 Failed to read schema document ' http://www.springframework.org/schema/tx/spring-tx.xsd' etc for:
<mvc:annotation-driven/> and <tx:annotation-driven transaction-manager="myTransactionManager" /> elements
in my spring configuration file i had these two urls
在我的 spring 配置文件中,我有这两个 url
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
in xsi:schemaLocation, which i replaced with
在 xsi:schemaLocation 中,我将其替换为
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
Actually visit these two sites http://www.springframework.org/schema/mvc/and http://www.springframework.org/schema/tx/and just added the latest version of spring-mvc and spring-tx i.e, spring-mvc-4.2.xsd and spring-tx-4.2.xsd as shown above.
实际上访问这两个站点 http://www.springframework.org/schema/mvc/和http://www.springframework.org/schema/tx/并且刚刚添加了最新版本的 spring-mvc 和 spring-tx 即, spring-mvc-4.2.xsd 和 spring-tx-4.2.xsd 如上所示。
In my opinion specifying version no explicitly is a good practice. It worked for me, hope this works for you too. Thank you.
在我看来,明确指定版本号是一个好习惯。它对我有用,希望这对你也有用。谢谢你。
回答by shashin
I tried modifying the xml as mentioned in the other solutions but none of them worked for me. In the end I tried opening the schema location file on a web browser but it wouldn't connect either (even though internet was working fine). Was the spring framework server down?
我尝试修改其他解决方案中提到的 xml,但没有一个对我有用。最后,我尝试在 Web 浏览器上打开架构位置文件,但它也无法连接(即使互联网工作正常)。spring框架服务器宕机了吗?
Turns out the Internet Security software that we use had to be turned onto access this site. So try opening the schema file in a web browser to verify that the URL is correct and that you can connect to it especially if the configuration was working fine previously.
原来的互联网安全软件,我们使用了被打开的访问这个网站。因此,请尝试在 Web 浏览器中打开架构文件以验证 URL 是否正确以及您是否可以连接到它,尤其是在配置之前运行良好的情况下。