为什么我在拿走pluginManagement时能够创建wsdl?

时间:2016-12-05 19:19:25

标签: eclipse maven wsdl cxf maven-plugin

我的整个pom.xml如下。有了这个pom,我在Eclipse中遇到了这个错误“生命周期配置未涵盖的插件执行:org.apache.cxf:cxf-java2ws-plugin:3.1.8:java2ws(执行:进程类,阶段:进程类)”。 不过,它确实可以正常工作。我的意思是,如果我“mvn clean package install”我得到了所需的输出wsdl文件。

如果我添加了pluginManagement,那么Eclipse中的错误会消失,但是我没有得到所需的wsdl文件,我的控制台中也没有出现错误。我发现的两个最接近的讨论是“Publishing wsdl java M2E plugin execution not covered”和“How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds”,但我不理解它们。据我所知,我们的想法是改变以利用

"<lifecycleMappingMetadata>...<action><execute/>".

我的直接问题是:当我带走插件管理时,为什么我的下方pom会起作用?我想,不确定,我缺少关于pluginManagement和执行之间关系的基本知识。我问题中最相关的部分不是Eclipse的内容(我发现很少有人说要忽略它)。

我一直在使用pluginManagement,但我从来不知道它为我的pom添加了多少额外的功能。从现在开始,它失败了java2ws,我真的很想知道我是否应该在我的pom中添加任何额外的配置,以便使用pluginManagement和目标&gt; java2ws来运行它。

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>grp</groupId>
    <artifactId>art</artifactId>
    <packaging>war</packaging>

    <version>0.0.1-SNAPSHOT</version>
    <name>art Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <properties>
        <jdk.version>1.8</jdk.version>
        <cxf.version>3.1.8</cxf.version>
        <spring.version>4.3.4.RELEASE</spring.version>
        <!-- <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> -->
    </properties>

    <dependencies>
        <!-- Spring dependencies -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- Apache cxf dependencies -->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <!-- servlet & jsp -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>art</finalName>
        <!-- <pluginManagement> -->

            <plugins>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.2</version>
                    <configuration>
                        <source>${jdk.version}</source>
                        <target>${jdk.version}</target>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-java2ws-plugin</artifactId>
                    <version>${cxf.version}</version>
                    <executions>
                        <execution>
                            <id>process-classes</id>
                            <phase>process-classes</phase>
                            <configuration>

                                <className>art.VmxService</className>

                                <outputFile>${project.basedir}/src/main/resources/VmxService.wsdl</outputFile>
                                <genWsdl>true</genWsdl>
                                <verbose>true</verbose>

                                <address>http://localhost:9080/art/VmxService</address>
                            </configuration>
                            <goals>
                                <goal>java2ws</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
<!--        </pluginManagement> -->
    </build>
</project>

1 个答案:

答案 0 :(得分:0)

pluginManagement部分提供与dependencyManagement部分类似的用途。它定义了插件及其版本和配置默认值,而没有实际将它们添加到maven构建生命周期。

在模块中添加插件后,它将从pluginManagement部分获取配置。

另见:Maven: What is pluginManagement?

因此,如果在多个模块中使用相同插件的类似配置,您可以在一个地方收集它们。如果插件只在一个模块中使用,我更喜欢直接将它放在构建中。但两种方式都有效。

请记住,您还需要将该插件添加到build.plugins中 - 只需将它们放在pluginManagement中即可。

eclipse中的警告更多地涉及IDE的生命周期。它与maven生命周期略有不同,在某些情况下它无法检测(或不能?)插件应该在什么时候运行。如果没有maven项目,某些插件也无法执行。所以我永远不确定生命周期映射插件试图解决什么:/

无论如何:如果你使用maven构建生成类,这对你有用(在告诉eclipse“没有maven的情况下构建项目”时没有完成)你很好。

我认为信息(生命周期映射)现在直接插入到插件中并由m2eclipse插件读取。我在一些插件中看到过这样的xml文件。因此,可能根本不需要生命周期映射插件。