英文:
How make cxf-codegen-plugin generate Webservices from jakarta.xml.ws?
问题
迁移从Java 8到Java 11。
将cxf-codegen-plugin从版本3.2.0升级到3.3.6。
插件仍然使用javax.jws.*而不是jakarta.jws.*从wsdl文件生成Java存根:
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
/**
- 此类由Apache CXF 3.3.6生成
- 2020-08-12T19:22:40.406+02:00
- 生成的源代码版本:3.3.6
*/
我是否理解错误,即javax.jws已被弃用,应该更改为jakarta.jws?
我如何实现使用所需包生成代码?
英文:
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?
答案1
得分: 8
问题已在CXF-8371中解决。
如果您升级到版本大于4.0.0,它将生成jakarta.jws而不是javax.jws。
英文:
Issue has been resolved in CXF-8371
If you upgrade to version >4.0.0 it will generate jakarta.jws instead of javax.jws.
答案2
得分: 5
尝试在生成源代码阶段使用maven-replacer-plugin,在我的情况下,我在目标文件夹上生成客户端文件,然后在那里替换包。
<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>
英文:
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>
答案3
得分: 1
在我们的情况下,配置如下:
<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>
英文:
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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论