oracle 重复定义:'identifiedType'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5005901/
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
Duplicated definition for: 'identifiedType'
提问by Aravias
I have a web application where i am using spring 3.0 and oracle's XMLTYPE related jar's com.oracle.xdb which in turn depends on com.oracle.xml.xmlparserv2 , iam sure most of you aware of the exception that you get when these jars are used with spring 3.0 as below,
我有一个 Web 应用程序,我在其中使用 spring 3.0 和 oracle 的 XMLTYPE 相关的 jar 的 com.oracle.xdb,而后者又依赖于 com.oracle.xml.xmlparserv2,我相信你们中的大多数人都知道当这些 jar 是与 spring 3.0 一起使用,如下所示,
Caused by: oracle.xml.parser.schema.XSDException: Duplicated definition for: 'identifiedType'
引起:oracle.xml.parser.schema.XSDException:重复定义:'identifiedType'
there are some suggestions to use a different parser like xerces, but in our case since we use the xdb dependency, it looks like we cannot change it to use another parser other than com.oracle.xml.xmlparserv2, it was working fine with spring 2.5.6 is there any info on when this would be fixed either by spring/oracle?
有一些建议可以使用不同的解析器,如 xerces,但在我们的例子中,由于我们使用了 xdb 依赖项,看起来我们无法将其更改为使用 com.oracle.xml.xmlparserv2 以外的其他解析器,它在 spring 中运行良好2.5.6 是否有任何有关 spring/oracle 何时修复此问题的信息?
回答by Shane
Instead of modifying xmlparserv2.jar
you can add
xmlparserv2.jar
您可以添加而不是修改
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
Click hereto read a post on Oracle's forums talking about the issue.
单击此处阅读 Oracle 论坛上讨论该问题的帖子。
回答by Pau Giner
I have identified that the problem is due to the inhability of xmlparserv2 to appropriately parse the xsi:schemaLocation
attribute.
我已经确定问题是由于 xmlparserv2 无法正确解析xsi:schemaLocation
属性。
I have checked that this works:
我已经检查过这是否有效:
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
While this produces the eror:
虽然这会产生错误:
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
The workaround is to remove the use of specific namespaces (such as tx, util..) and replace them by the equivalent definitions using common beans. For example, you can replace <tx:annotation-driven/>
with <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
解决方法是移除特定命名空间(例如 tx、util..)的使用,并将它们替换为使用通用 bean 的等效定义。例如,您可以替换<tx:annotation-driven/>
为<bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
回答by Marcin Jancewicz
Remove /META-INF/services directory from xmlparserv2.jar - it's content registers Oracle's parser.
从 xmlparserv2.jar 中删除 /META-INF/services 目录 - 它的内容注册 Oracle 的解析器。
回答by Matt M
Step 4of my answer hereexplains why it happens and a few approaches to fixing it.
步骤4的我的答案在这里解释了为什么会发生和几个接近固定它。
回答by lukaszwrzaszcz
Consistent versioning
schema/beans/spring-beans**-3.1**.xsd schema/jee/spring-jee**-3.1**.xsd schema/mvc/spring-mvc**-3.1**.xsd
etc.The order is important. spring-jee-3.1.xsdbefore spring-beans-3.1.xsdcauses error, because in spring-jee-3.1.xsd file we have an import reference to spring-beans-3.1.xsd
一致的版本控制
schema/beans/spring-beans**-3.1**.xsd schema/jee/spring-jee**-3.1**.xsd schema/mvc/spring-mvc**-3.1**.xsd
等。顺序很重要。spring-jee-3.1.xsd之前spring-beans-3.1.xsd导致错误,因为在 spring-jee-3.1.xsd 文件中我们有一个对 spring-beans-3.1.xsd 的导入引用
回答by lukaszwrzaszcz
If two schemas have an import to the same XSD, you should import that XSD as well to prevent "duplicated definition" error.
如果两个模式都导入到同一个 XSD,您也应该导入该 XSD 以防止“重复定义”错误。
For example: I have three schemas:
例如:我有三个模式:
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
Now I'm getting an errror, because spring-util and spring-jee have an imports to:
现在我得到了一个错误,因为 spring-util 和 spring-jee 有一个导入:
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-4.2.xsd"/>
<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-4.2.xsd"/>
When spring-tool will be imported manually BEFORE spring-util and spring-jee:
在 spring-util 和 spring-jee 之前手动导入 spring-tool 时:
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/tool/spring-tool-4.2.xsd
http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
the XML configuration will be properly parsed.
XML 配置将被正确解析。
Obviously, you should have consistient versions.
显然,您应该有一致的版本。
Small workaround is to define some part of configuration in other files with described different schemas and import it using:
小的解决方法是在具有描述的不同模式的其他文件中定义配置的某些部分并使用以下方法导入它:
<import resource="part_of_config.xml"/>