Pluginmanagement标记导致maven构建失败

时间:2017-08-22 07:10:59

标签: java maven maven-2 portlet spring-portlet-mvc

当我将maven项目导入我的ecliplse-luna时,我在pom.xml中遇到错误

Plugin execution not covered by lifecycle configuration: org.apache.portals.pluto:maven-pluto-plugin:2.1.0-M3:assemble (execution: default, phase: 
 generate-resources)

所以我在pom.xml中包含了<Pluginmanagement>标记,它解决了错误。当我运行 mvn clean package / install 时,由于以下错误(相对路径\ pluto-resources \ web.xml由maven-pluto-plugin创建),构建失败了

on project MyFirstPortlet: The specified web.xml file 'D:\PORTLET-SAMPLES\MyFirstPortlet\target\pluto-resources\web.xml' does not exist

我从pom.xml中删除了<Pluginmanagement>标记并运行maven构建,现在maven构建成功了。

问题是,如果pom.xml中存在<Pluginmanagement>标记,则eclipse项目导入不会抛出任何错误,但maven构建失败。如果<Pluginmanagement>不存在,则maven构建成功,但eclipse项目导入失败。

我的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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.helloworld</groupId>
    <artifactId>MyFirstPortlet</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>MyFirstPortlet Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>org.apache.portals</groupId>
            <artifactId>portlet-api_2.0_spec</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <!-- bind 'pluto2:assemble' goal to 'process-resources' lifecycle -->
                <!-- This plugin will read your portlet.xml and web.xml and injects required 
                    lines -->
                <plugin>
                    <groupId>org.apache.portals.pluto</groupId>
                    <artifactId>maven-pluto-plugin</artifactId>
                    <version>2.1.0-M3</version>
                    <executions>
                        <execution>
                            <phase>generate-resources</phase>
                            <goals>
                                <goal>assemble</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <!-- configure maven-war-plugin to use updated web.xml -->
                <!-- This plugin will make sure your WAR will contain the updated web.xml -->
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <finalName>MyFirstPortlet</finalName>
    </build>
</project>

任何人都可以告诉我为什么添加插件管理导致构建失败以及如何解决eclipse中没有生命周期错误的插件执行而没有插件管理标记。

0 个答案:

没有答案