2009-06-26 85 views
4

我试图执行使用Maven的EXEC我的项目:EXEC目标,我一直试图在这个片段中进行配置:的Maven 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不是一个罐子。

任何想法?

回答

1

试着把configuration放在execution之内。

+0

配置元素不属于此插件的执行元素内部。 – 2009-07-14 13:48:06

6

我看到您的代码有一个问题。您需要将-jar放入其自己的argument元素中。如果你不知道,你会得到一个错误。你的其他代码已经死了。这是我的一个项目的一个实例。这会在执行mvn package后执行打包在目标目录中的jar。如果仍然出现相同的错误,我会尝试从本地存储库中删除插件以获取全新副本。还要确保插件不在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> 
+0

我遇到同样的问题,因为它在`pluginsManagement`而不是`plugins`中。 – Sydney 2011-04-22 20:41:53