source

다음에 대한 중복된 정의: '유형'

bestscript 2023. 9. 17. 18:20

다음에 대한 중복된 정의: '유형'

저는 spring 3.0과 oracle의 XMLTYPE 관련 jar의 com.oracle.xmlparserv2에 의존하는 com.oracle.xmlparserv2를 사용하는 웹 어플리케이션이 있습니다. 아래와 같이 spring 3.0과 함께 사용할 때 예외가 발생한다는 것을 대부분 알고 계실 것입니다.

발생 원인: oracle.xml.parser.도식의XSD 예외:다음에 대한 중복된 정의: '유형'

xerces와 같이 다른 파서를 사용하자는 제안이 있지만, 우리의 경우 xdb 종속성을 사용하기 때문에 com.jp.xml.xmlparserv2가 아닌 다른 파서를 사용하도록 변경할 수 없을 것으로 보입니다. 스프링 2.5.6으로 잘 작동하고 있었습니다. 스프링/스프링 중에 언제 수정되는지에 대한 정보가 있습니까?

수정하는 대신xmlparserv2.jar추가할 수 있습니다.

-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

Oracle 포럼에서 이 문제에 대해 이야기하는 게시물을 보려면 여기를 클릭하십시오.

나는 그 문제가 xmlparserv2가 적절하게 파싱할 수 없기 때문이라는 것을 확인했습니다.xsi:schemaLocation기여하다.

작동하는지 확인했습니다.

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"

이렇게 하면 오류가 발생합니다.

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"

해결 방법은 특정 네임스페이스(tx, util.. 등)의 사용을 제거하고 일반 콩을 사용하여 동등한 정의로 대체하는 것입니다.예를 들어 다음을 대체할 수 있습니다.<tx:annotation-driven/>와 함께<bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>

xmlparserv2.jar에서 /META-INF/services 디렉토리를 제거합니다. 이 디렉토리의 내용은 Oracle의 파서를 등록합니다.

여기서 제 답변4단계는 왜 이런 일이 발생하는지와 그것을 해결하기 위한 몇 가지 접근법에 대해 설명합니다.

  1. 일관 버전 관리
    schema/beans/spring-beans**-3.1**.xsd schema/jee/spring-jee**-3.1**.xsd schema/mvc/spring-mvc**-3.1**.xsd
    기타.

  2. 순서가 중요합니다. spring-beans-3.1.xsd 이전spring-jee-3.1.xsd 파일에서 spring-beans-3.1.xsd에 대한 가져오기 참조가 있기 때문에 오류가 발생합니다.

두 스키마가 동일한 XSD로 가져오는 경우, "중복 정의" 오류를 방지하기 위해 해당 XSD도 가져와야 합니다.

예를 들어,세 가지 스키마가 있습니다.

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

스프링-유틸과 스프링-지가 다음과 같이 수입하기 때문에 오류가 발생합니다.

<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"/>

스프링-유틸 및 스프링-지 이전에 스프링-공구를 수동으로 가져올 때:

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

XML 구성을 올바르게 구문 분석합니다.

당연히 일관된 버전이 있어야 합니다.

소규모 해결 방법은 설명된 다른 스키마를 사용하여 다른 파일에 구성의 일부를 정의하고 다음을 사용하여 가져오는 것입니다.

<import resource="part_of_config.xml"/>

언급URL : https://stackoverflow.com/questions/5005901/duplicated-definition-for-identifiedtype