maven-jaxb2-plugin在linux机器上没有编译xsd但在windows上工作?

时间:2015-06-19 13:29:04

标签: java linux windows xsd maven-jaxb2-plugin

以下是pom.xml的代码片段

            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.8.3</version>
            </plugin>

这是例外

   [INFO] --- maven-jaxb2-plugin:0.8.3:generate (default) @ customer-project ---
   [ERROR] Error while parsing schema(s).Location [ file:....Customer.xsd{12,97}].
    org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'customer:CustomerApplication' to a(n) 'element declaration' component.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
        at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:2537)

第一个XSD相关部分

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://www.cohbe.org/CustomerRequest"
            xmlns:customer="http://www.cohbe.org/customer"
            targetNamespace="http://www.cohbe.org/CustomerRequest"
            elementFormDefault="qualified">
    <xsd:import schemaLocation="CustomerDetails.xsd"
              namespace="http://www.cohbe.org/customer"/>
    <xsd:element name="CustomerNewRequest">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="customer:CustomerApplicationDetail" minOccurs="0"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    ...
</xsd:schema>

CustomerDetails.xsd(嵌套XSD)位置与First XSD相同。这是相关部分

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema version="2.15" 
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns="http://www.cohbe.org/customer"
            targetNamespace="http://www.cohbe.org/customer"
            xmlns:countries="http://www.cohbe.org/Counties"
            elementFormDefault="qualified">
    <!-- Version 2.15 -->
    <xsd:import namespace="http://www.cohbe.org/states" schemaLocation="States.xsd"/>
    <xsd:element name="CustomerApplicationDetail"
               type="CustomerApplicationDetail"/>
    <xsd:complexType name="CustomerApplicationDetail">

    .....
    </xsd:schema>

2 个答案:

答案 0 :(得分:1)

您是说通过本地文件导入的架构在Windows上运行但在Linux上运行?这很奇怪,相对的本地进口总是在每个测试项目中都有效 这让我相信您的构建环境存在问题。检查文件是否存在以及构建过程是否有权访问文件。

一般:

  • 使用较新的版本,当前为0.12.3,您使用的是0.8.3,超过2年。
  • 提供mvn -X -e clean install日志。
  • 提供最小的复制测试项目作为PR here - 例如在e/emily下(或您希望的任何p/project-name)。记住lincense

答案 1 :(得分:0)

我遇到了同样的问题,即完全有效的XSD无法在Linux上编译但在Windows和Mac上运行。我不得不在maven-jaxb-2插件配置中关闭严格验证,如下所示:

<configuration>
    <schemaDirectory>src/main/resources/xsd</schemaDirectory>
    <strict>false</strict>
    <extension>true</extension>
</configuration>