for*_*has 17 spring xsd spring-data
我在Eclipse中有一个maven-spring项目,我在我的一个spring语境中有这个烦人的错误信息:
引用文件包含错误(jar:file:/M2_HOME/repository/org/springframework/spring-beans/3.1.2.RELEASE/spring-beans-3.1.2.RELEASE.jar!/ org/springframework/beans/factory/xml /spring-tool-3.1.xsd).有关更多信息,请右键单击"问题视图"中的消息,然后选择"显示详细信息..."
演出的秘密导致了这个:

我使用spring-data-jpa 1.2.0.RELEASE,其余的春季罐子是3.1.3.RELEASE.关于spring-data-commons-core - 我甚至没有依赖于我的pom中的这个jar,但我可以在我的m2存储库中看到它以及spring-data-commons-parent和版本1.4.0.RELEASE ,我不知道为什么(也许那些是spring-data-jpa的一部分?).
我的应用上下文架构:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd">
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我一直收到这个错误.基本上它没有任何影响,应用程序编译,部署和运行就好了,这只是Eclipse中令人讨厌的红色错误标记让我疯狂:)
Uli*_*ses 20
我最近在最新的Eclipse(Kepler)中遇到了类似的问题,并通过在Preferences> XML> XML Files> Validation中禁用"Honor all XML schema locations"选项来修复它.它禁用对指向不同模式位置的相同名称空间的引用的验证,仅对正在验证的XML文件中找到的第一个名称空间进行验证.此选项来自Xerces库.
WTP Doc:http://www.eclipse.org/webtools/releases/3.1.0/newandnoteworthy/sourceediting.php
Xerces Doc:http://xerces.apache.org/xerces2-j/features.html#honour-all-schemaLocations
for*_*has 12
我通过做三件事来解决它:
将此存储库添加到我的POM:
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>http://repo.springsource.org/libs-milestone</url>
</repository>
Run Code Online (Sandbox Code Playgroud)我正在使用这个版本的spring-jpa:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)我从我的上下文中删除了xsd版本(虽然我不确定是否有必要):
Run Code Online (Sandbox Code Playgroud)<?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" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx" 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/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">
我希望这有帮助.
我使用spring-data-jpa-1.3做的是向xsd添加一个版本并将其降低到1.2.然后错误消息消失.像这样
<beans
xmlns="http://www.springframework.org/schema/beans"
...
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
...
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.2.xsd">
Run Code Online (Sandbox Code Playgroud)
似乎它固定为1.2但后来再次出现在1.3中.
有时spring config xml文件在下一次Eclipse打开时效果不佳。
它显示了由于架构定义导致的xml文件错误,无论重新打开eclipse还是清理项目都无法正常工作。
但是尝试一下!
右键单击spring config xml文件,然后选择
validate。
片刻之后,错误消失,eclipse告诉您该文件没有错误。
真是笑话...
我最近在 Spring 4.0 上遇到了同样的问题。
这是由spring-beans-4.0.xsd和 的名称冲突引起的spring-context-4.0.xsd。打开spring-context-4.0.xsd你可以看到spring-beans-4.0.xsd导入如下:
<xsd:import namespace="http://www.springframework.org/schema/beans"
schemaLocation="http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"/>
Run Code Online (Sandbox Code Playgroud)
这些名称的冲突使 Eclipse 抱怨“...架构不能包含两个具有相同名称的全局组件...”
一个值得注意的方面是我在 Eclipse Kepler SR2 上没有这个问题,但在 Eclipse Luna SR1 上没有这个问题,比较两个关于 XML 验证的偏好,它们是相同的。
它是通过从 xsi:schemaLocation 属性中删除 spring-context-4.0.xsd 来解决的:
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
Run Code Online (Sandbox Code Playgroud)
在此之后,一切都按预期进行。
| 归档时间: |
|
| 查看次数: |
80827 次 |
| 最近记录: |