JAXB2 基础知识 可合并插件:设置自定义合并策略
我已经在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你需要有2个参数。一种用于激活可合并插件,另一种用于指定自定义合并策略类。
You need to have 2 arguments. One to activate mergeable plugin and one to specify the custom merge strategy class.