如何从 Pom.xml 中的 WSDL 生成 Java 源代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5140240/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to generate Java source from WSDL in Pom.xml?
提问by jimmy
I have a pom file which is generating source from WSDL files which is designed something like this.
我有一个 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>
This is working really fine. And both the wsdl files are generated in the packageName (com.test.hello.soap
) but I want the wsdl file with Id2 to be generated in a separate packageName or location.
这工作得很好。并且这两个 wsdl 文件都是在 packageName ( com.test.hello.soap
)中生成的,但我希望在单独的 packageName 或位置中生成带有 Id2 的 wsdl 文件。
Can someone tell me how to do that please?
有人可以告诉我怎么做吗?
采纳答案by joelittlejohn
The <configuration>
tag at the bottom of your example defines config values that are common between the two executions.
<configuration>
示例底部的标记定义了两次执行之间通用的配置值。
If you want the value of <packageName>
to have one value for Id1 and another value for Id2, you simply need to move the <packageName>
config value into the <configuration>
block for each execution.
如果您希望 的值<packageName>
对 Id1 有一个值,对 Id2 有另一个值,您只需要将<packageName>
配置值移动到<configuration>
每次执行的块中。
So, it looks like :
所以,它看起来像:
<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>