I generate server/client from my wsdl/xsd's using the cxf-codegen-plugin for Maven. All the types created have default no-arg-constructors, which makes them a pain to work with.
Is there any way to make Apache CXF generate a full constructor aswell, with all the members of the class as arguments?
This plugin is just a fancy wrapper around xjc.
There are two xjc plugins that address your problem space:
You need to add the required dependencies and then configure the plugin to enable those plugins in xjc, e.g.
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<configuration>
<defaultOptions>
<extraargs>
<extraarg>-xjc-Xvalue-constructor</extraarg>
</extraargs>
</defaultOptions>
</configuration>
<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.4</version>
</dependency>
</dependencies>
</plugin>
Note: the above makes this a default for all executions, if you want to enable those options for a specific execution only, then just add the <configuration>
bit into that specific execution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With