Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cxf: generate jaxb constructor with arguments

Is there a way in CXF to generate JAXB classes with full constructors (i.e., with the members of the class as arguments)?

like image 927
Philippe Blayo Avatar asked Oct 17 '11 11:10

Philippe Blayo


1 Answers

Use the value-constructor xjc plugin.

Maven snippet:

        <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>
like image 148
artbristol Avatar answered Nov 06 '22 14:11

artbristol