簡體   English   中英

maven-jaxb2-plugin無法在Linux機器上編譯xsd,但可以在Windows上運行?

[英]maven-jaxb2-plugin not compiling xsd on linux machine but works on windows?

這是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(Nested 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>

您是說通過本地文件導入架構可以在Windows上運行,但不能在Linux上運行? 奇怪的是,相對本地進口始終有效,並且幾乎在每個測試項目中都存在。
這使我相信您的構建環境存在問題。 檢查文件是否存在以及構建過程是否有權訪問文件。

一般:

  • 使用更新的版本,當前為0.12.3,您使用的是0.8.3以上的版本,已有2年的歷史了。
  • 提供mvn -X -e clean install日志。
  • 在此處提供一個最小的可復制測試項目作為PR-例如在e/emily (或您希望使用的任何p/project-name )。 留香

我遇到了同樣的問題,即完全有效的XSD無法在Linux上編譯,但可以在Windows和Mac上工作。 我不得不在maven-jaxb-2插件配置中關閉嚴格驗證,如下所示:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM