XmlSchemaCollection.read()的NoSuchMethodError

时间:2012-10-04 14:04:53

标签: java xml spring

我为XmlSchemaCollection.read(Lorg / xml / sax / InputSource;)保留了NoSuchMethodError,我发现旧版本的XMLSchema What happened to: org.apache.ws.commons.schema.XmlSchemaCollection.read(InputSource)存在问题。 我改变了maven依赖,但错误不断重复。

Caused by: java.lang.NoSuchMethodError: org.apache.ws.commons.schema.XmlSchemaCollection.read(Lorg/xml/sax/InputSource;)Lorg/apache/ws/commons/schema/XmlSchema;
at org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection.afterPropertiesSet(CommonsXsdSchemaCollection.java:137)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 55 more

maven依赖

<dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-xml</artifactId>
        <version>2.1.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.apache.ws.xmlschema</groupId>
        <artifactId>xmlschema-core</artifactId>
        <version>2.0.3</version>
    </dependency>

架构集合bean

<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
    <property name="xsds" value="/message.xsd"/>
    <property name="inline" value="true"/>
</bean>

2 个答案:

答案 0 :(得分:4)

可能是某些其他库依赖于xmlschema-core的旧版本。 检查

mvn dependency:tree

如果你看到其他库中的xmlschema-core作为依赖项,那么尝试通过在父依赖项上使用排除来排除它 see Dependency Exclusions

答案 1 :(得分:0)

另一种选择是; 如果你的项目pom.xml中有问题或缺少artifactId,这个问题也会持续存在。