cxf:使用参数生成jaxb构造函数

时间:2011-10-17 11:18:56

标签: java constructor jaxb cxf

CXF中是否有一种方法可以生成具有完整构造函数的JAXB类(即,将类的成员作为参数)?

1 个答案:

答案 0 :(得分:11)

使用value-constructor xjc插件。

Maven片段:

        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <defaultOptions>
                            <extraargs>
                                <extraarg>-xjc-Xvalue-constructor</extraarg>
                            </extraargs>
                        </defaultOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-value-constructor</artifactId>
                    <version>3.0</version>
                </dependency>
                <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics</artifactId>
                    <version>0.6.2</version>
                </dependency>
            </dependencies>
        </plugin>