JAXB2 基础知识 可合并插件:设置自定义合并策略

发布于 2024-11-19 05:50:21 字数 1676 浏览 4 评论 0原文

我已经在 ant 脚本中成功激活了 JAXB2 Basics 'Mergeable' 插件,如下所示:

<target name="generate-sources" depends="clean">

<xjc destdir="${generated.src.dir}" package="${jaxb.package}" extension="true">
  <arg line="
    -Xmergeable
    -Xinheritance"/>

  <binding dir="${altova}">
    <include name="**/*.xjb"/>
  </binding>

  <schema dir="${altova}">
    <include name="**/*.xsd"/>
  </schema>

  <!-- Plugins -->
  <classpath>
    <fileset dir="${xjc.lib}">

      <!-- JAXB2 Basics library -->
      <include name="jaxb2-basics-*.jar"/>

      <!-- JAXB2 Basics library dependencies -->
      <include name="jaxb2-basics-tools-*.jar"/>
      <include name="commons-beanutils-*.jar"/>
      <include name="commons-lang-*.jar"/>
      <include name="commons-logging-*.jar"/>
    </fileset>

    <fileset dir="${webapp.lib}">
      <include name="jaxb2-basics-runtime-*.jar"/>
    </fileset>

    <!-- Contains custom strategy classes -->
    <pathelement location="${webapp.classes}"/>

  </classpath>
</xjc>

它正在工作,并且正确地将“MergeFrom”接口添加到我生成的类中。

我的问题是,每当我尝试使用“mergeStrategyClass”参数指定自定义合并策略时,“MergeFrom”接口就会从生成的类中完全消失。我使用的语法如下:

<arg line="
    -Xmergeable-mergeStrategyClass=com.acme.foo.CustomMergeStrategy
    -Xinheritance"/>

这直接取自 JAXB2 基础网站上的示例。 (类路径似乎没问题,因为当我故意拼错类时,我得到了 ClassNotFoundException)

ant 构建没有抛出任何错误,并且类已成功生成,除了缺少接口之外。

I have successfully activated the JAXB2 Basics 'Mergeable' plugin in an ant script as follows:

<target name="generate-sources" depends="clean">

<xjc destdir="${generated.src.dir}" package="${jaxb.package}" extension="true">
  <arg line="
    -Xmergeable
    -Xinheritance"/>

  <binding dir="${altova}">
    <include name="**/*.xjb"/>
  </binding>

  <schema dir="${altova}">
    <include name="**/*.xsd"/>
  </schema>

  <!-- Plugins -->
  <classpath>
    <fileset dir="${xjc.lib}">

      <!-- JAXB2 Basics library -->
      <include name="jaxb2-basics-*.jar"/>

      <!-- JAXB2 Basics library dependencies -->
      <include name="jaxb2-basics-tools-*.jar"/>
      <include name="commons-beanutils-*.jar"/>
      <include name="commons-lang-*.jar"/>
      <include name="commons-logging-*.jar"/>
    </fileset>

    <fileset dir="${webapp.lib}">
      <include name="jaxb2-basics-runtime-*.jar"/>
    </fileset>

    <!-- Contains custom strategy classes -->
    <pathelement location="${webapp.classes}"/>

  </classpath>
</xjc>

It is working, and correctly adding the 'MergeFrom' interface to my generated classes.

My problem is that whenever I try to specify a custom merging strategy using the 'mergeStrategyClass' argument, the 'MergeFrom' interface disappears entirely from the generated class. The syntax I am using is as follows:

<arg line="
    -Xmergeable-mergeStrategyClass=com.acme.foo.CustomMergeStrategy
    -Xinheritance"/>

This is taken straight from the example on the JAXB2 Basics website. (The classpath seems to be fine, as when I deliberately miss-spell the class, I get a ClassNotFoundException)

There are no errors being thrown by the ant build, and the classes are generated successfully, except for the missing interface.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

属性 2024-11-26 05:50:21

你需要有2个参数。一种用于激活可合并插件,另一种用于指定自定义合并策略类。

-Xmergeable

-Xmergeable-mergeStrategyClass=com.acme.foo.CustomMergeStrategy

You need to have 2 arguments. One to activate mergeable plugin and one to specify the custom merge strategy class.

-Xmergeable

-Xmergeable-mergeStrategyClass=com.acme.foo.CustomMergeStrategy

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文