如何强制让Sonatype Nexus更新?

20

我正在尝试在我的pom.xml中使用onejar-maven-plugin插件:

<plugin>
    <groupId>org.dstovall</groupId>
    <artifactId>onejar-maven-plugin</artifactId>
    <version>1.4.4</version>
    <executions>
        <execution>
            <configuration>
                <mainClass>com.exmaple.myproj.MpPort_MpSoapPort_Client</mainClass>
                <onejarVersion>0.97</onejarVersion>
                <attachToBuild>true</attachToBuild>
                <classifier>onejar</classifier>
            </configuration>
            <goals>
                <goal>one-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<pluginRepositories>
    <pluginRepository>
        <id>onejar-maven-plugin.googlecode.com</id>
        <url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
    </pluginRepository>
</pluginRepositories>

但由于某种原因,尝试通过Eclipse Maven插件(Maven install)构建它会导致构建错误:

Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository onejar-maven-plugin.googlecode.com (http://onejar-maven-plugin.googlecode.com/svn/mavenrepo)
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2)
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.dstovall:onejar-maven-plugin

Reason: POM 'org.dstovall:onejar-maven-plugin' not found in repository: Unable to download the artifact from any repository

  org.dstovall:onejar-maven-plugin:pom:1.4.4

from the specified remote repositories:
  Nexus (https://mynexus.example.com/nexus/content/repositories/central)

 for project org.dstovall:onejar-maven-plugin

所以我手动下载了onejar-maven-plugin.jar,然后通过命令行安装,但似乎出现了类似的错误:

C:\Users\daniel\myproj>mvn install:install-file -Dfile=onejar-maven-plugin-1.4.4.jar -DgroupId=com.jolira -DartifactId=onejar-maven-plugin -Dversion=1.4.4 -Dpackaging=jar
[INFO] Scanning for projects...
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository onejar-maven-plugin.googlecode.com (http://onejar-maven-plugin.googlecode.com/svn/mavenrepo)
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2)
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.dstovall:onejar-maven-plugin

Reason: POM 'org.dstovall:onejar-maven-plugin' not found in repository: Unable to download the artifact from any repository

  org.dstovall:onejar-maven-plugin:pom:1.4.4

from the specified remote repositories:
  Nexus (https://mynexus.example.com/nexus/content/repositories/central)

 for project org.dstovall:onejar-maven-plugin

据我所知,因为我们有一个不包含特定构件的 Nexus 镜像,导致事情变得混乱。

因此,我尝试按照如何强制 Sonatype Nexus 重新生成 / 重建其元数据中的说明操作,但是在我们的 Sonatype Nexus 上“浏览索引”选项卡没有这样的上下文菜单!

enter image description here

我在这里读到 "Nexus 只缓存客户端请求的构件。因此,您需要设置您的项目 POM 文件以请求正确的版本",但是这正是我一直在做的 -- 没有任何结果上的变化。

我该如何摆脱这个“鸡生蛋蛋生鸡”的局面,并将这个 onejar-maven-plugin ver. 1.4.4 放入我的 Nexus 镜像中?

(或者,我怎样才能将它放入我的本地 .m2 缓存中?)


在我的情况下,Nexus 机器上没有剩余空间。 - Ahmet Koylu
1个回答

32
你可以通过使用-U强制Maven更新并重新请求依赖项,即使本地repo包含有关不可用的工件的元数据。

您可以通过使用-U选项强制Maven更新并重新请求依赖项,即使本地存储库中包含有关不可用工件的元数据。

mvn clean install -U 

应该可行。

同时,您应该更改您的settings.xml,将其指向公共组而不仅仅是直接的中央库。更多信息可以在Nexus书籍中找到。

您应该注意,中央仓库没有您正在尝试使用的onejar插件。查看搜索结果,并查看groupIdcom.joilira而不是org.dstovall

此外,如果您真的想使用来自org.dstovallonejar插件,您应该将网址http://onejar-maven-plugin.googlecode.com/svn/mavenrepo/作为代理存储库添加到Nexus中,并将其添加到公共组中,然后在您的settings.xml中使用公共组。


我本来也想建议暂时注释掉他的settings.xml中的<mirrors>元素(作为至少将包装入本地.m2缓存的解决方法),但随后注意到你有一个更出色的见解:他的Nexus指向com.jolira而不是com.dstoval。对此给予加分! - sfinja
1
这是pom.xml文件引用错误,与Nexus无关。 - Manfred Moser
但如果你看他提供的截图,他的Nexus确实指向了一个nejar-maven-plugin,只不过它来自于jolira而不是dstoval。这难道不是导致他的maven安装失败的原因吗? - sfinja
不...他的Maven设置导致尝试从中央下载,正如您从错误消息中看到的https://mynexus.example.com/nexus/content/repositories/central/所示。 - Manfred Moser
问题在于他的Maven设置在pom文件中有一个被忽略的pluginRepo,因为他在settings文件中使用mirrorOf *和那里的中央仓库。 - Manfred Moser
结果证明你们两个都是对的。是的,我的settings.xml指向的是中央而不是公共,但实际上导致我的问题的根本原因是没有注意到groupId是不同的。 - Withheld

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接