簡體   English   中英

JAXB Maven使用多個情節生成類

[英]JAXB Maven generate classes using multiple episodes

使用這個maven插件 ,我能夠生成我的類並在另一個模式中重用它們。 真的很棒!

現在,我發現自己的模式需要兩個情節(從模式生成的兩個不同的程序包)。 我只是試圖在XJC中添加另一個arg,但是沒有用。

然后,我更改了兩個參數的順序,並且該錯誤針對了另一個模式。 然后,我了解到這兩個情節都可以,但可能不是這樣做的方式。

這是我的一些pom:

<execution>
    <id>business</id>
    <goals>
        <goal>generate</goal>
    </goals>
    <configuration>
      ..
      <extension>true</extension>
      <args>
        <arg>-b</arg>
        <arg>${project.basedir}/target/episodes/x.episode</arg>
        <arg>${project.basedir}/target/episodes/y.episode</arg>
        <arg>${project.basedir}/target/episodes/z.episode</arg>
      </args>
      ..
    </configuration>
</execution>

這就是我得到的:

org.xml.sax.SAXParseException; systemId:文件:/ ****。episode; lineNumber:2; columnNumber:65; s4s-elt-schema-ns:名稱空間元素“綁定”必須來自“ http://ww.w3.org/2001.XMLSchema ”。

根據我的理解(在調換了他們的調用后),這三種模式/情節很好,但是我不能同時使用它們。 有什么辦法嗎?

新手在這里,任何幫助,不勝感激:)。

在另一個項目上,我之前已經做過。 我認為您使用的是錯誤的語法:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <id>jaxb-Generic-XSD</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>xjc</goal>
            </goals>
            <configuration>
                <enableIntrospection>false</enableIntrospection>
                <schemaFiles>Generic.xsd</schemaFiles>
                <schemaDirectory>${jaxb.schema.folder}</schemaDirectory>
                <packageName>you.package.name.here</packageName>
                <outputDirectory>${jaxb.output.folder}</outputDirectory>
                <extension>true</extension>
                <arguments>-b ${core.episode.file} -b ${containers.episode.file}</arguments>
            </configuration>
        </execution>
    </executions>
</plugin>

請注意: <arguments>-b ${core.episode.file} -b ${containers.episode.file}</arguments>行。

我認為您使用的是同一個Maven插件,但是如果沒有,請記下插件版本groupId,artifactId,並改用它。

這里是作者。

為什么使用args ,為什么不只在配置中添加情節呢?

<episodes>
    <episode>
        <groupId>com.acme.foo</groupId>
        <artifactId>package1</artifactId>
        <!-- Version is not required if the artifact is
            configured as dependency -->
    </episode>
    <episode>
        <groupId>com.acme.foo</groupId>
        <artifactId>package2</artifactId>
        <!-- Version is not required if the artifact is
            configured as dependency -->
    </episode>
</episodes>

情節的整個想法是,您可以指向JAR(包含情節文件),XJC會從包含的情節中查找並使用綁定。 -b一起使用arg不是其原意。 :)

關於您看到的錯誤,我猜您配置arg的方式使XJC認為您的第二集和后續集實際上是模式。 我會嘗試將-b參數設為中間,或者將您引用的所有情節配置在一個arg

但是我仍然認為這不是使用劇集的正確方法。 將您的情節編譯為單獨的JAR /單獨的Maven模塊,將它們用作依賴項,並將其配置為episodes或者僅打開useDependenciesAsEpisodes選項。

暫無
暫無

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

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