Maven Exec插件无法读取配置
我正在尝试使用Maven exec:exec目标执行我的项目,并且尝试使用以下代码段对其进行配置:
I'm trying to execute my project using the Maven exec:exec goal and I've tried to configure it with this snippet:
<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
时,我得到输出:
When I run mvn exec:exec
I get the output:
------------------------------------------------------------------------
[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而不是一个罐子.
I've tried reorganising the <plugin>
everyway I can think of but nothing makes any difference? The project is a POM not a jar.
有什么想法吗?
我看到您的代码存在一个问题.您需要将-jar放入其自己的argument
元素.否则,您将得到一个错误.您的其余代码完全是错误的.这是我的一个项目的工作示例.执行mvn package
之后,将执行打包在目标目录中的jar.如果仍然出现相同的错误,我将尝试从本地存储库中删除插件以获取新副本.还要确保插件不在pluginsManagement
元素中.如果失败,则发布整个POM.
I see one issue with your code. You need to put -jar into its own argument
element. You will get an error if you don't. The rest of your code is dead on acurate. Here is a working example from one of my projects. This executes a jar that is packaged in the target directory after executing mvn package
. If you still get the same error I would try deleting the plugin from your local repository to get a fresh copy. Also ensure that the plugin is not in the pluginsManagement
element. If that fails, post your entire 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>