我必须在 Ant 脚本中使用 JAXB 从 XML Schema 文件生成类。当我以默认方式执行此操作时,一切顺利。后来我意识到我需要每个类的值构造函数。我尝试为 XJC 使用 value-constructor 插件,但是当我运行 Ant 脚本时出现错误:
BUILD FAILED
c:\HOME\plt\owf2-testing\EdytorScenariuszy\build.xml:17:
java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin: Provider org.jvnet.jaxb2_commons.plugin.value_constructor.ValueConstructorPlugin not a subtype
at java.util.ServiceLoader.fail(ServiceLoader.java:214)
at java.util.ServiceLoader.access$300(ServiceLoader.java:164)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:352)
at java.util.ServiceLoader$1.next(ServiceLoader.java:428)
at com.sun.tools.xjc.Options.findServices(Options.java:957)
at com.sun.tools.xjc.Options.getAllPlugins(Options.java:374)
at com.sun.tools.xjc.Options.parseArgument(Options.java:688)
at com.sun.tools.xjc.Options.parseArguments(Options.java:809)
at com.sun.tools.xjc.XJC2Task._doXJC(XJC2Task.java:474)
at com.sun.tools.xjc.XJC2Task.doXJC(XJC2Task.java:457)
at com.sun.tools.xjc.XJC2Task.execute(XJC2Task.java:380)
at com.sun.istack.tools.ProtectedTask.execute(ProtectedTask.java:103)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
这是我的蚂蚁脚本:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<project name="EdytorScenariuszy" default="createClasses">
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
<classpath>
<pathelement path="lib/jaxb-xjc.jar"/>
<pathelement path="lib/jaxb-impl.jar"/>
<pathelement path="lib/jaxb2-value-constructor.jar"/>
</classpath>
</taskdef>
<target name="clean">
<delete dir="src/xml" />
</target>
<target name="createClasses" depends="clean">
<xjc schema="scenariuszTestowy.xsd" binding="mapowanieTypow.xjb" destdir="src" package="xml" encoding="UTF-8">
<arg value="-Xvalue-constructor"/>
</xjc>
</target>
</project>
如果有人可以帮助我如何处理此异常,我将不胜感激。