gpt4 book ai didi

java - 生成 java 类到 src 不仅以 maven cxf-codegen-plugin 为目标

转载 作者:行者123 更新时间:2023-12-01 18:07:05 27 4
gpt4 key购买 nike

我已经编写了一个 .wsdl 文件,现在想使用 maven 从它生成源代码。我已将以下内容添加到 Maven:

<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>

<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>\src\main\java\wsdlgenerated</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>\src\main\resources\wsdl\myWsdl.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>

当我运行maven clean install时,代码仅生成到target文件夹,而不是src

最佳答案

尝试使用此标签 ${basedir} 和 ${project.build.directory} 在 src 文件夹中生成类

<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>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/myService.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>

关于java - 生成 java 类到 src 不仅以 maven cxf-codegen-plugin 为目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60542622/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com