【问题标题】:Maven can't find org.codehaus.mojo:exec-maven-plugin at command lineMaven 在命令行中找不到 org.codehaus.mojo:exec-maven-plugin
【发布时间】:2018-11-22 06:39:36
【问题描述】:

我继承了一个孤立的 Java 8/Maven 项目,并正在尝试构建。在自述文件中,我看到了运行以下命令的说明:

mvn -o -q -Dexec.executable="echo" -Dexec.args='${project.version}' org.codehaus.mojo:exec-maven-plugin:exec

当我从项目根目录(包含pom.xml)运行该文件时,我收到此错误:

[ERROR] Error resolving version for plugin 'org.codehaus.mojo:exec-maven-plugin' from the repositories [local (/Users/myuser/.m2/repository), central (https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginVersionResolutionException

看起来它正在尝试使用this plugin 通过echo 打印project.version

我想知道我需要做什么才能使其正常工作,听起来 Maven 在其配置为查看的任何存储库中都找不到 org.codehaus.mojo:exec-maven-plugin,但我不知道是否:

  1. 我需要向我的pom.xml 添加另一个存储库配置;或
  2. 我需要在本地+手动安装org.codehaus.mojo:exec-maven-plugin,以便Maven可以找到并执行它;或
  3. 发生了其他事情

有什么想法吗?!

【问题讨论】:

    标签: java maven maven-plugin


    【解决方案1】:

    您指定 -o 作为 Maven 的参数。它的意思是“离线”。有了它,您将无法下载依赖项。
    另请注意,您可以指定插件的版本以确保下载插件,因为您的实际错误表明:

    插件的错误解析版本

    运行独立目标不需要该版本,但您不调用独立目标。

    所以试试类似的东西:

     mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}'
     org.codehaus.mojo:exec-maven-plugin:1.6.0:exec
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-20
      • 1970-01-01
      • 2016-11-24
      • 1970-01-01
      • 2020-08-07
      • 1970-01-01
      • 2012-01-07
      • 2013-12-03
      相关资源
      最近更新 更多