我正在尝试的解决方案使用episodes。在通用模式的 POM 文件中,我有这样的内容:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<bindingDirectory>${basedir}/src/bindings</bindingDirectory>
<!-- The schema directory or xsd files. -->
<schemaDirectory>${basedir}/src/schema</schemaDirectory>
<!-- The working directory to create the generated java source files. -->
<outputDirectory>${build.directory}/generated-sources/jaxb</outputDirectory>
<arguments>-episode "${build.directory}/generated-sources/myCommonSchema.episode"</arguments>
</configuration>
</execution>
</executions>
</plugin>
这里的关键是<arguments>-episode "${build.directory}/generated-sources/myCommonSchema.episode"</arguments>
- 这会生成一个剧集文件(在指定目录中名为“myCommonSchema.episode”)。下一步是将剧集文件复制到依赖于公共模式的 Web 服务,并将其作为绑定文件引用,如下所示:
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>MyService</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<bindingDirectory>${basedir}/src/</bindingDirectory>
<bindingFiles>
<bindingFile>myCommonSchema.episode</bindingFile>
</bindingFiles>
<wsdlDirectory>${basedir}/src/wsdl/MyWebService</wsdlDirectory>
<wsdlFiles>
<wsdlFile>MyWebService.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>META-INF/wsdl/MyWebService/MyWebService.wsdl</wsdlLocation>
<sourceDestDir>${project.build.directory}/generated-sources/wsimport</sourceDestDir>
<verbose>true</verbose>
<xdebug>true</xdebug>
<extension>true</extension>
<xjcArgs>
<xjcArg>-Xannotate</xjcArg>
</xjcArgs>
</configuration>
</execution>
我仍在对此进行测试,但它似乎有效。唯一尴尬的部分是将剧集文件移动到其他客户端,但可能有一种方法可以自动化。