无法执行目标 org.codehous.mojo:exec-maven-plugin:1.4.0:java

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31951269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 11:49:15  来源:igfitidea点击:

Failed to execute goal org.codehous.mojo:exec-maven-plugin:1.4.0:java

javamaven

提问by xtheking

I've been trying to run this Maven program all day but to no avail. I keep getting this error:

我一整天都在尝试运行这个 Maven 程序,但无济于事。我不断收到此错误:

[ERROR] Failed to execute goal org.codehous.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project get-with-jersey: The parameters ‘mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java are missing or invalid

[错误] 无法在项目 get-with-jersey 上执行目标 org.codehous.mojo:exec-maven-plugin:1.4.0:java (default-cli):目标 org.codehaus.mojo 的参数“mainClass”: exec-maven-plugin:1.4.0:java 丢失或无效

After running mvn exec:java.

运行后mvn exec:java

mvn clean installworks fine and builds, but running the program fails.

mvn clean install工作正常并构建,但运行程序失败。

I downloaded and placed the plugin for 1.4.0 where I believe Maven lets all it's plugins exist, but I can't figure out why it keeps crashing.

我下载并放置了 1.4.0 的插件,我相信 Maven 允许它的所有插件存在,但我不知道为什么它一直崩溃。

Here is my pom.xml.

这是我的 pom.xml。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bridge.rest.jersey</groupId>
<artifactId>get-with-jersey</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Get Request with Jersey</name>

<repositories>
    <repository>
        <id>maven2-repository.java.net</id>
        <name>Java.net Repository for Maven</name>
        <url>http://download.java.net/maven/2/</url>
        <layout>default</layout>
    </repository>
</repositories>

<dependencies>

    <!--
    <dependency>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
    </dependency>
    -->

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.9</version>
    </dependency>

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.9</version>
    </dependency>

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.9</version>
    </dependency>

    <dependency> 
        <groupId>org.hsqldb</groupId> 
        <artifactId>hsqldb</artifactId> 
        <version>2.0.0</version> 
    </dependency>

</dependencies>

Thanks for your help, looking forward to your answers!

感谢您的帮助,期待您的解答!

采纳答案by M Anouti

You have not specified the main class to run:

您尚未指定要运行的主类:

mvn exec:java -Dexec.mainClass=foo.bar.MainClass

http://www.mojohaus.org/exec-maven-plugin/java-mojo.html

http://www.mojohaus.org/exec-maven-plugin/java-mojo.html