如何使用maven的jaxb_commons插件 [英] How to use jaxb_commons plugins from maven

查看:279
本文介绍了如何使用maven的jaxb_commons插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jaxb插件将接口插入到从maven生成类的choice元素中。问题是我似乎无法从maven中弄清楚如何这样做,文档中的存储库并不清楚,唯一的例子(下图)不起作用,它似乎忽略了插件(maven报告没有关于找不到它的错误)或者插件没有项目文档中当前列出的所有附加组件:

I'm trying to use a jaxb plugin to insert a interface into a choice element generating the classes from maven. The problem is that I can't seem to figure out how to do so from maven, the repository isn't clear from the documentation and the only example (bellow) doesn't work, it seems to ignore the plugin (maven reports no error about not finding it) or the plugin doesn't have all the adds-ons currently listed in the project documentation:

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.6.1</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <generatePackage>br.com.wonder.nfe.xml</generatePackage>
        <args>
            <arg>-Xifins</arg>
        </args>
        <plugins>
            <plugin>
                <groupId>org.jvnet.jaxb2_commons</groupId>
                <artifactId>basic</artifactId>
                <version>0.4.1.5</version>
            </plugin>
        </plugins>
    </configuration>
</plugin>

我在根pom中有这些:

I have these in the root pom:

<pluginRepositories>
    <pluginRepository>
        <id>maven2-repository.dev.java.net</id>
        <url>http://download.java.net/maven/2</url>
    </pluginRepository>
    <pluginRepository>
        <id>maven-repository.dev.java.net</id>
        <name>Java.net Maven 1 Repository (legacy)</name>
        <url>http://download.java.net/maven/1</url>
        <layout>legacy</layout>
    </pluginRepository>
</pluginRepositories>

运行时给出:

错误时设置CmdLine选项'[-Xifins,-episode,/ home / administrador / JavaApp /wnfe3 / winfe-ejb / target / generate-sources / xjc / META-INF / sun-jaxb.episode]'!

Error while setting CmdLine options '[-Xifins, -episode, /home/administrador/JavaApp/wnfe3/wnfe-ejb/target/generated-sources/xjc/META-INF/sun-jaxb.episode]'!

嵌入式错误:无法识别的参数-Xifins

Embedded error: unrecognized parameter -Xifins

推荐答案

不幸的是,它看起来像界面注入插件不再受到良好支持。事实上,我很难找到下载的JAR。

Unfortunately, it looks like the interface injection plugin is no longer well supported. In fact, I'm having trouble finding the JAR for download.

谢天谢地, JAXB2 Basics插件提供了一种类似的机制,用于向生成的JAXB存根添加接口(参见继承插件)。

Thankfully, the JAXB2 Basics Plugins provides a similar mechanism for adding an interface to the generated JAXB stubs (see the Inheritance plugin).

JAXB2 Basics插件可以在java.net Maven存储库中找到。

The JAXB2 Basics plugin is available in the java.net Maven repository.

使用继承插件,你的POM将如下所示:

Using the Inheritance plugin, your POM will look like:

<build>
  <plugins>
    <plugin>
      <groupId>org.jvnet.jaxb2.maven2</groupId>
      <artifactId>maven-jaxb2-plugin</artifactId>
      <version>0.6.2</version>
      <executions>
        <execution>
          <goals>
            <goal>generate</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <extension>true</extension>
        <args>
          <arg>-Xinheritance</arg>
        </args>
        <plugins>
          <plugin>
            <groupId>org.jvnet.jaxb2_commons</groupId>
               <artifactId>jaxb2-basics</artifactId>
               <version>0.5.3</version>
           </plugin>
        </plugins>
      </configuration>
    </plugin>
    ...
  </plugins>
  ...
</build>

继承插件文档有一个例子,说明你的JAXB Bindings的样子。为方便起见,我再现了以下示例:

The Inheritance plugin documentation has an example for what your JAXB Bindings would look like. For your convenience, I've reproduced the example below:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
    jaxb:version="2.1"
    jaxb:extensionBindingPrefixes="inheritance">

    <!-- ... -->

    <xs:complexType name="WillBeMadeCloneableType">
        <xs:annotation>
            <xs:appinfo>
                <inheritance:implements>java.lang.Cloneable</inheritance:implements>
            </xs:appinfo>
        </xs:annotation>
        <!-- ... -->
    </xs:complexType>
    <!-- ... -->
</xs:schema>

这篇关于如何使用maven的jaxb_commons插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆