本文介绍了在Maven 2的命令行中设置插件的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我生成默认的快速入门Maven示例,并键入mvn checkstyle:checkstyle,它始终尝试使用最新的SNAPSHOT版本.在我的Nexus服务器中,可能是错误的,但是如何在Maven 2的命令行中设置插件的版本,例如2.5而不是2.6-SNAPSHOT呢?

I generate default quickstart Maven example, and type mvn checkstyle:checkstyle, it always try to use the lastest SNAPSHOT version. Probably it is wrong in my Nexus server, but how can I set plugin's version on the command line in Maven 2, like 2.5 for checkstyle instead of 2.6-SNAPSHOT?

C:\HelloWorld>mvn checkstyle:checkstyle
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'checkstyle'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).

Project ID: org.apache.maven.plugins:maven-checkstyle-plugin

Reason: Error getting POM for 'org.apache.maven.plugins:maven-checkstyle-plugin' from  the repository: Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.
  org.apache.maven.plugins:maven-checkstyle-plugin:pom:2.6-SNAPSHOT

from the specified remote repositories:
  nexus (http://localhost:9081/nexus/content/groups/public)

for project org.apache.maven.plugins:maven-checkstyle-plugin

我想可能是mvn checkstyle:2.5:checkstyle,不幸的是不是.

I guess it could be mvn checkstyle:2.5:checkstyle, unfortunately it is not.

当然,如果我在pom.xml中设置了构建依赖关系,它将起作用,但是我想看看命令行如何起作用.

Surely if I set build dependance in pom.xml, it will work, but I want to see how command line can work.

推荐答案

如果您不想运行本地存储库中安装的插件的最新版本,则需要设置版本号.为此,您需要以以下形式指定完全合格的目标:

If you don't want to run the latest version of a plugin installed in your local repository, you need to set the version number. And for that, you need to specify a fully-qualified goal in the form of:

mvn groupID:artifactID:version:goal

所以在您的情况下:

mvn org.apache.maven.plugins:maven-checkstyle-plugin:2.5:checkstyle

这篇关于在Maven 2的命令行中设置插件的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 12:18