Maven exec插件多次执行不起作用

时间:2013-11-28 10:30:50

标签: maven maven-3

当我以下列方式调用exec:java目标时,我试图让Maven exec插件运行多次执行:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <id>first</id>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <mainClass>com.example.First</mainClass>
                    </configuration>
                </execution>
                <execution>
                    <id>second</id>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <mainClass>com.example.Second</mainClass>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

但是在使用maven 3.1.1运行mvn exec:java时,我收到错误消息:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project test: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java are missing or invalid -> [Help 1]

为单次执行运行exec:java目标(不使用嵌套的executions元素)按预期工作。

1 个答案:

答案 0 :(得分:2)

在我看来,问题是<execution/>都与特定的<phase/>无关。尝试设置一个。