'How make cxf-codegen-plugin generate Webservices from jakarta.xml.ws?
Migrating from Java 8 to Java 11.
Updated cxf-codegen-plugin from version 3.2.0 to 3.3.6.
Plugin still generates Java stubs from wsdl files using packages from javax.jws.* instead of from jakarta.jws.*:
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
/**
* This class was generated by Apache CXF 3.3.6
* 2020-08-12T19:22:40.406+02:00
* Generated source version: 3.3.6
*
*/
Am I getting it wrong that javax.jws is deprecated and should be changed to jakarta.jws?
And how do I accomplish code generation with desired packages?
Solution 1:[1]
Try using maven-replacer-plugin at generated-source phase, in my case I generate client files on target folder and then replace package there
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>replace-for-jakarta</id>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<filesToInclude>target/generated/**/*.java</filesToInclude>
<preserveDir>true</preserveDir>
<replacements>
<replacement>
<token>javax.jws</token>
<value>jakarta.jws</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
Solution 2:[2]
in our case the configuration was like this:
<configuration>
<filesToInclude>${project.build.directory}/generated-sources/cxf/**/*.java</filesToInclude>
<preserveDir>true</preserveDir>
<replacements>
<replacement>
<token>javax.xml.bind</token>
<value>jakarta.xml.bind</value>
</replacement>
<replacement>
<token>javax.annotation</token>
<value>jakarta.annotation</value>
</replacement>
<replacement>
<token>javax.jws</token>
<value>jakarta.jws</value>
</replacement>
<replacement>
<token>javax.xml.ws</token>
<value>jakarta.xml.ws</value>
</replacement>
</replacements>
</configuration>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | harryssuperman |