4

我正在尝试使用 Maven exec:exec 目标执行我的项目,并尝试使用以下代码段对其进行配置:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1.1</version>
    <configuration>
        <executable>java</executable>
        <arguments>
            <argument>-jar ${staging.dir}/project.jar</argument>
        </arguments>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
</plugin>

当我运行时,mvn exec:exec我得到输出:

------------------------------------------------------------------------
[ERROR]BUILD ERROR
------------------------------------------------------------------------
One or more required plugin parameters are invalid/missing for 'exec:exec'

[0] Inside the definition for plugin 'exec-maven-plugin' specify the following:

<configuration>
  ...
  <executable>VALUE</executable>
</configuration>

-OR-

on the command line, specify: '-Dexec.executable=VALUE'

我已经尝试重新组织<plugin>我能想到的一切,但没有任何区别?该项目是 POM 而不是 jar。

有任何想法吗?

4

2 回答 2

6

我发现您的代码存在一个问题。您需要将 -jar 放入它自己的argument元素中。如果你不这样做,你会得到一个错误。你的代码的其余部分已经死了。这是我的一个项目中的一个工作示例。这会执行一个jar,执行后打包在目标目录中mvn package。如果您仍然遇到相同的错误,我会尝试从您的本地存储库中删除插件以获取新副本。还要确保插件不在pluginsManagement元素中。如果失败,请发布您的整个 POM。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1.1</version>
    <executions>
        <execution>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <executable>java</executable>
        <workingDirectory>/target</workingDirectory>            
        <arguments>
            <argument>-jar</argument>
            <argument>${project.build.directory}/${project.build.finalName}.jar</argument>
        </arguments>          
    </configuration>
</plugin>
于 2009-07-14T13:47:29.057 回答
1

试着把configuration里面的execution.

于 2009-06-26T11:18:18.190 回答