我尝试运行两次MOJO的exec-maven-plugin,但它抱怨mainClass没有设置。有了这个my.Main,我想生成几个文件,并且必须在编译阶段完成它们。我做错了什么?使用正确的参数为两个执行设置mainClass。
我的pom.xml包含:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<id>ABC_FALSE</id>
<phase>generate-sources</phase>
<configuration>
<mainClass>my.Main</mainClass>
<arguments>
<argument>-abc</argument>
<argument>false</argument>
</arguments>
</configuration>
<goals>
<goal>java</goal>
</goals>
</execution>
<execution>
<id>ABC_TRUE</id>
<phase>generate-sources</phase>
<configuration>
<mainClass>my.Main</mainClass>
<arguments>
<argument>-abc</argument>
<argument>true</argument>
</arguments>
</configuration>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
</plugin>
运行后
mvn exec:java
我收到此错误
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:java (default-cli) on project exec-generation: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.3.2:java are missing or invalid.
祝你好运, SK
答案 0 :(得分:0)
试试这个:
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>exucute_the_executable_jar_1</id>
<phase>generate-resources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>the.Main</mainClass>
<arguments>
<argument>a</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>exucute_the_executable_jar_2</id>
<phase>generate-resources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>the.Main</mainClass>
<arguments>
<argument>b</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
...
通过使用此命令调用maven:
mvn package
好的,我在 generate-resources 阶段使用了它,但您可以更改它。
祝你好运, grafl