Maven Exec插件没有读取配置

Cog*_*gsy 4 maven-2 maven-plugin

我正在尝试使用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>
Run Code Online (Sandbox Code Playgroud)

当我运行时,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'
Run Code Online (Sandbox Code Playgroud)

我已经尝试过重新组织<plugin>我能想到的每一个但没有任何区别的东西?该项目是一个POM而不是一个罐子.

有任何想法吗?

Dan*_*tes 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>
Run Code Online (Sandbox Code Playgroud)