2016-12-05 43 views
0

我的整个pom.xml如下。有了这个pom,我在Eclipse中得到了这个错误:“生命周期配置中没有涉及的插件执行:org.apache.cxf:cxf-java2ws-plugin:3.1.8:java2ws(execution:process-classes,phase:process-classes)”。 尽管如此,它确实工作正常。我的意思是,如果我“mvn clean package install”,我得到所需的输出wsdl文件。当我拿走pluginManagement时,为什么我能够创建wsdl?

如果我添加了pluginManagement,Eclipse中的错误desapears,但我没有得到所需的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/>". 

我直的问题优点是:为什么当我带走pluginManagement不低于我的工程POM?我猜,我不确定是否缺少关于pluginManagement和执行之间关系的基本知识。我的问题中最相关的部分不是什么与Eclipse的worng(我发现很少人说忽略它)。

我一直在使用pluginManagement,但我从来不知道它为我的pom添加了什么额外功能。由于现在使用java2ws失败,我真的很想知道是否应该在我的pom中添加任何额外的配置,以便通过pluginManagement和goal> 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> 

回答

0

pluginManagement部分提供类似于dependencyManagement部分的用途。它定义了插件及其版本和配置默认值,但实际上并未将它们添加到Maven构建生命周期中。

一旦插件被添加到模块中,它将从pluginManagement部分获取配置。

另见:Maven: What is pluginManagement?

因此,如果同一插件的类似的配置在多个模块使用,你可以将它们汇总到一个地方。如果插件仅用于一个模块,我更愿意直接将它放在构建中。但这两种方式都有效。

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

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

反正:如果你使用maven构建生成这些类并且这对你有用(当你告诉eclipse'build'时没有这样做,项目没有maven)你很好。

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

+0

Wemu,你肯定回答了我的问题100%。如果你是Eclipse用户,最后一个评论,你知道如何引发“eclipse中的警告更多地涉及到你的IDE的生命周期”吗? – DemeCarvO

+1

对不起,我不熟悉日食的演变。我简单地忽略了过去的生命周期映射警告。这可能只是某个地方的验证设置?通常,Eclipse中的每个警告都可以被禁用或优先级改变。 – wemu

相关问题