简体   繁体   English

jaxb2-basics-annotate 与 jaxws-maven-plugin 配置

[英]jaxb2-basics-annotate with jaxws-maven-plugin configuration

I have a maven configuration using the jaxws-maven-plugin to generate the class files from the wsdl.我有一个 maven 配置,使用 jaxws-maven-plugin 从 wsdl 生成类文件。

I am trying to get the jaxb2-basics-annotate plugin to work with the generation to allow me to add some annotations to the generated output.我试图让 jaxb2-basics-annotate 插件与生成一起工作,以允许我向生成的输出添加一些注释。

The specific plugin configuration is:具体插件配置为:

   <pluginManagement>
        <plugins>
            <plugin>
                <!-- This is the WSIMPORT plugin used to generate code from WSDL -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <!-- Keep generated files -->
                    <keep>true</keep>
                    <!-- generated source files destination-->
                    <sourceDestDir>target/generated-sources</sourceDestDir>
                    <!-- this is so the xsd files can be accessed -->
                    <vmArgs>
                        <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
                    </vmArgs>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>

... ...

           <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <dependencies>
                <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics-annotate</artifactId>
                    <version>1.0.2</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>travel-itinerary</id>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <extension>true</extension>
                        <!--<args>-->
                            <!--<arg>-Xannotate</arg>-->
                        <!--</args>-->

When I have the args commented out I get the following error:当我将 args 注释掉时,我收到以下错误:

[ERROR] Using " http://annox.dev.java.net " customizations requires the "-Xannotate" switch to enable this plug-in. [错误] 使用“ http://annox.dev.java.net ”定制需要“-Xannotate”开关来启用这个插件。

When I have the args being used I get the following error message:当我使用 args 时,我收到以下错误消息:

unrecognized parameter -Xannotate无法识别的参数 -Xannotate

Usage: wsimport [options]用法:wsimport [选项]

where [options] include:其中 [选项] 包括:

I would greatly appreciate if someone could fill in the gap in my configuration to get the annotation plugin working with the jaxws-maven-plugin.如果有人可以填补我的配置中的空白以使注释插件与 jaxws-maven-plugin 一起工作,我将不胜感激。

You might set the -X Flags to xjcArgs insteadt of args您可以将 -X 标志设置为xjcArgs不是args

 <xjcArgs>
    <xjcArg>-Xannotate</xjcArg>
 </xjcArgs>

I found the solution here .我在这里找到了解决方案。 By adding the -Dcom.sun.tools.xjc.XJCFacade.nohack=true system property, I was able to resolve the issue.通过添加-Dcom.sun.tools.xjc.XJCFacade.nohack=true系统属性,我能够解决该问题。

我花了一些时间,但最终我找到了一个对我有用的组合:可能最重要的事情是同时做:定义 xjcArg: -Xannotate 并在插件中定义对 org.jvnet.jaxb2_commons:jaxb2-basics-annotate 的依赖定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM