【问题标题】:Maven: extract files from jarMaven:从jar中提取文件
【发布时间】:2011-11-19 10:19:16
【问题描述】:

我正在开发 WebService 的客户端应用程序,并且我在 jar 中有相应的 WSDL 文件。

我正在使用 ant 使用以下 build.xml 从 wsdl 生成 java 代码:

<project name="wsimport" default="wsimport" basedir=".">
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport" />

  <target name="wsimport">
     <echo message="Starting wsimport"/>
     <mkdir dir="target/generated-sources/jaxws-wsimport"/>
     <wsimport
        wsdl="???"
        sourcedestdir="target/generated-sources/jaxws-wsimport"
        extension="true"
        verbose="true"
        target="2.0"
        xnocompile="true"
        catalog="src/jax-ws-catalog.xml"
        wsdlLocation="/MyWebService/MyWebServiceV1_0?wsdl">
        <binding dir="src/main/resources/bindings/v1_0" includes="*.xml"/>
        <xjcarg value="-XhashCode"/>
        <xjcarg value="-Xequals"/>
        <xjcarg value="-XtoString"/>
     </wsimport>

   </target>
</project>

如何从 jar 加载 WSDL 文件? WSDL 引用了同样在同一个 jar 中的 XSD。

【问题讨论】:

    标签: maven wsdl jax-ws


    【解决方案1】:

    回答我自己的问题,我使用的方法是从 jar 中提取文件。

    其实我是用maven构建项目,用antrun插件从wsdl生成源码,所以我用maven-dependency-plugin解压jar文件:

                <!-- extract WSDL and XSD from dependency jar -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>unpack</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>my.company</groupId>
                                        <artifactId>my.artifact</artifactId>
                                        <version>1.0</version>
                                        <outputDirectory>${project.build.directory}/wsdl</outputDirectory>
                                        <includes>**\/*.xsd, **\/*.wsdl</includes>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-28
      • 1970-01-01
      • 1970-01-01
      • 2011-07-03
      • 1970-01-01
      相关资源
      最近更新 更多