gpt4 book ai didi

java - 如何从 Pom.xml 中的 WSDL 生成 Java 源代码?

转载 作者:行者123 更新时间:2023-11-30 11:55:12 26 4
gpt4 key购买 nike

我有一个 pom 文件,它从设计如下的 WSDL 文件生成源代码。

    <executions>
<execution>
<id>Id1</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlLocation>wsdl/HelloService.wsdl</wsdlLocation>
<wsdlFiles>
<wsdlFile>HelloService.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>
${project.build.directory}/jaxws/stale/HelloService.wsdl.stale
</staleFile>
</configuration>
</execution>
<execution>
<id>Id2</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlLocation>wsdl/GoodByeService.wsdl</wsdlLocation>
<wsdlFiles>
<wsdlFile>GoodByeService.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>
${project.build.directory}/jaxws/stale/GoodByeService.wsdl.stale
</staleFile>
</configuration>
</execution>
</executions>
<configuration>
<target>2.1</target>
<xjcArgs>
<xjcArg>-XautoNameResolution</xjcArg>
</xjcArgs>
<bindingDirectory>src/jaxws</bindingDirectory>
<keep>true</keep>
<wsdlDirectory>src/jaxws/wsdl</wsdlDirectory>
<packageName>com.test.hello.soap</packageName>
</configuration>

这工作得很好。并且两个 wsdl 文件都在 packageName (com.test.hello.soap) 中生成,但我希望在单独的 packageName 或位置中生成带有 Id2 的 wsdl 文件。

有人能告诉我怎么做吗?

最佳答案

<configuration>示例底部的标记定义了两次执行之间通用的配置值。

如果你想要<packageName>的值要为 Id1 设置一个值并为 Id2 设置另一个值,您只需移动 <packageName>配置值到 <configuration>每次执行都会阻塞。

所以,它看起来像:

<executions>
<execution>
<id>Id1</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlLocation>wsdl/HelloService.wsdl</wsdlLocation>
<wsdlFiles>
<wsdlFile>HelloService.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>
${project.build.directory}/jaxws/stale/HelloService.wsdl.stale
</staleFile>
<!-- packageName value for Id1 -->
<packageName>com.test.hello.soap</packageName>
</configuration>
</execution>
<execution>
<id>Id2</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlLocation>wsdl/GoodByeService.wsdl</wsdlLocation>
<wsdlFiles>
<wsdlFile>GoodByeService.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>
${project.build.directory}/jaxws/stale/GoodByeService.wsdl.stale
</staleFile>
<!-- packageName value for Id2 -->
<packageName>com.test.goodbye.soap</packageName>
</configuration>
</execution>
</executions>
<configuration>
<target>2.1</target>
<xjcArgs>
<xjcArg>-XautoNameResolution</xjcArg>
</xjcArgs>
<bindingDirectory>src/jaxws</bindingDirectory>
<keep>true</keep>
<wsdlDirectory>src/jaxws/wsdl</wsdlDirectory>
<!-- packageName has been removed from here -->
</configuration>

关于java - 如何从 Pom.xml 中的 WSDL 生成 Java 源代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5140240/

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