Maven:wsgen目标错过了javax / jws / WebService

时间:2019-01-27 18:00:20

标签: java eclipse maven jax-ws wsgen

我刚刚在Eclipse 2018-09中使用maven使用JAX-WS soap Web服务创建了一个愚蠢的EJB 3.2项目。编译似乎运行良好,但是当执行wsgenwsimport目标时,编译失败。 首先,我的Maven构建运行配置是

clean compile jaxws:wsgen install jaxes:wsimport

这是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>lory-ejb</groupId>
<artifactId>lory-ejb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>lory-ejb</name>

<dependencies>
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.3.6.Final</version>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>42.2.5</version>
    </dependency>

    <dependency>
        <groupId>javax.xml</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.1</version>
    </dependency>

    <dependency>
        <groupId>javax.xml</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.1</version>
    </dependency>

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
        <version>3.6.0</version>
    </dependency>

    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-tools</artifactId>
        <version>2.3.1</version>
        <type>pom</type>
    </dependency>

    <dependency>
        <groupId>org.glassfish.main.javaee-api</groupId>
        <artifactId>javax.jws</artifactId>
        <version>3.1.2.2</version>
    </dependency>

    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.3.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.1.1</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>2.5</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>generate-wsdl</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>wsgen</goal>
                    </goals>
                    <configuration>
                        <sei>org.lory.ejb.core.implementations.TestWorkupsWSImpl</sei>
                        <genWsdl>true</genWsdl>
                    </configuration>
                </execution>
                <execution>
                    <id>generate-stubs</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <wsdlDirectory>target/jaxws/wsgen/wsdl</wsdlDirectory>
                        <wsdlFiles>
                            <wsdlFile>TestWorkupsWSImpl.wsdl</wsdlFile>
                        </wsdlFiles>
                        <!-- *** you need the next line to set the wsdlLocation in the generated 
                            stubs *** -->
                        <wsdlLocation>http://localhost:8180/lory-ejb-0.0.1-SNAPSHOT/</wsdlLocation>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
                <execution>
                    <id>package-wsclient-jars</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <classesDirectory>target/jaxws/</classesDirectory>
                        <classifier>wsclient</classifier>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

这是我在控制台上看到的失败消息:

  

[INFO]扫描项目...   [警告]   [警告]在构建有效的lory-ejb:lory-ejb:jar:0.0.1-SNAPSHOT模型时遇到了一些问题   [警告] org.apache.maven.plugins:maven-jar-plugin的'build.plugins.plugin.version'丢失。 @ 133行,第12列   [警告] org.codehaus.mojo:jaxws-maven-plugin的'build.plugins.plugin.version'丢失。 @第99行,第12栏   [警告]   [警告]强烈建议修复这些问题,因为它们会威胁到您的构建的稳定性。   [警告]   [警告]因此,将来的Maven版本可能不再支持构建此类格式错误的项目。   [警告]   [信息]   [信息] ------------------------- ------------- -------------   [INFO]建筑物lory-ejb 0.0.1-SNAPSHOT   [INFO] -------------------------------- [jar] ------------ ---------------------   [警告] org.jboss:jandex:jar:2.0.5.FOM的POM无效,传递依赖项(如果有)将不可用,请启用调试日志记录以获取更多详细信息   [警告] com.sun.xml.ws:jaxws-tools:jar:2.2.10的POM无效,传递依赖项(如果有)将不可用,请启用调试日志记录以获取更多详细信息   [警告]工件javax.xml:jaxb-api:jar:2.1已重定位到javax.xml.bind:jaxb-api:jar:2.1   [信息]   [INFO] --- maven-clean-plugin:2.5:clean(default-clean)@ lory-ejb ---   [INFO]删除/ Users / lory / workspace / lory-ejb / target   [信息]   [INFO] --- maven-resources-plugin:2.6:resources(default-resources)@ lory-ejb ---   [警告]使用平台编码(实际上是UTF-8)来复制过滤的资源,即构建依赖于平台!   [INFO]正在复制1个资源   [信息]   [INFO] --- maven-compiler-plugin:3.8.0:compile(default-compile)@ lory-ejb ---   [INFO]检测到更改-重新编译模块!   [警告]尚未使用平台编码UTF-8设置文件编码,即构建依赖于平台!   [INFO]将16个源文件编译到/ Users / lory / workspace / lory-ejb / target / classes   [信息]   [INFO] --- jaxws-maven-plugin:2.5:wsgen(default-cli)@ lory-ejb ---   [INFO] ----------------------------------------------- -------------------------   [INFO]建立失败   [INFO] ----------------------------------------------- -------------------------   [INFO]总时间:3.665 s   [INFO]结束于:2019-01-27T18:57:06 + 01:00   [INFO] ----------------------------------------------- -------------------------   [错误]无法在项目lory-ejb上执行目标org.codehaus.mojo:jaxws-maven-plugin:2.5:wsgen(default-cli):执行目标org.codehaus.mojo:jaxws-maven-plugin的default-cli :2.5:wsgen失败:执行org.codehaus.mojo:jaxws-maven-plugin:2.5:wsgen:时缺少所需的类:javax / jws / WebService   [错误] ----------------------------------------------- ------   [错误]领域=插件> org.codehaus.mojo:jaxws-maven-plugin:2.5   [错误]策略= org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy   [错误]网址[0] =文件:/Users/lory/.m2/repository/org/codehaus/mojo/jaxws-maven-plugin/2.5/jaxws-maven-plugin-2.5.jar   [错误]网址[1] =文件:/Users/lory/.m2/repository/com/sun/xml/ws/jaxws-tools/2.2.10/jaxws-tools-2.2.10.jar   [错误]网址[2] =文件:/Users/lory/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar   [错误]网址[3] =文件:/Users/lory/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar   [错误]网址[4] =文件:/Users/lory/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar   [错误]网址[5] =文件:/Users/lory/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar   [错误]网址[6] =文件:/Users/lory/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar   [错误]网址[7] =文件:/Users/lory/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar   [错误]网址[8] =文件:/Users/lory/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar   [错误]网址[9] =文件:/Users/lory/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar   [错误]国外进口数量:1   [错误]导入:条目[从领域ClassRealm [maven.api,父级:null]导入]   [错误]   [错误] ----------------------------------------------- ------:javax.jws.WebService   [错误]-> [帮助1]   [错误]   [错误]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。   [错误]使用-X开关重新运行Maven以启用完整的调试日志记录。   [错误]   [ERROR]有关错误和可能的解决方案的详细信息,请阅读以下文章:   [错误] [帮助1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

我无法理解问题出在哪里,因为我在项目中的Maven Dependencies下看到了该类。我只是Maven的新手,因为我已经习惯了Ivy + Ant构建的工作。

也许,我写的依赖项过多还是太少? 而且我不知道为什么要怪它找不到终结点类和wsdl文件,因为它们在编译后仍必须执行。

有人可以解释一下吗?谢谢。

0 个答案:

没有答案