簡體   English   中英

從XSD架構生成JAXB類會導致奇怪的包結構

[英]JAXB classes generation from XSD schema results in a strange package structure

使用以下插件:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>xjc</id>
            <goals>
                <goal>xjc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
        <clearOutputDir>false</clearOutputDir>
    </configuration>
</plugin>

我從放置在/src/main/resources的XSD架構(例如, entity.xsd )生成類,具有名稱空間定義的根元素在以下示例中:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:webpage="https://www.mywebpage.com"
    targetNamespace="https://www.mywebpage.com"
    elementFormDefault="qualified">

    ...
</xs:schema>

在執行mvn clean installtarget/generated-sources/jaxb的生成結構很奇怪:

  • target/generated-sources/jaxb
    • https
      • www_mywebpage
        • ObjectFactory.java
        • Entity.java
        • EntityDetailsRequest.java
        • EntityDetailsResponse.java

我期望像這樣:

  • target/generated-sources/jaxb
    • com.mywebpage
      • ObjectFactory.java
      • Entity.java
      • EntityDetailsRequest.java
      • EntityDetailsResponse.java

我做錯了什么?

我在XSD架構中有一個錯誤。 maven-jaxb2-plugin無法識別https ,只能識別http

我變了:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:webpage="https://www.mywebpage.com"
    targetNamespace="https://www.mywebpage.com"

至:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:webpage="http://www.mywebpage.com"
    targetNamespace="http://www.mywebpage.com"

生成的結構與我的問題中所預期和描述的一樣。

暫無
暫無

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

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