cxf: generate jaxb constructor with arguments

后端 未结 1 789
隐瞒了意图╮
隐瞒了意图╮ 2021-02-03 13:05

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

相关标签:
1条回答
  • 2021-02-03 13:39

    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>
    
    0 讨论(0)
提交回复
热议问题