Maven Exec插件无法读取配置 [英] Maven Exec Plugin not reading configuration

查看:130
本文介绍了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>

这篇关于Maven Exec插件无法读取配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆