Nexus:找不到神器

rav*_*n99 10 caching repository nexus maven

最近我从Archiva迁移到了Sonatype Nexus.

我正在尝试使用来自第三方存储库的Jars,而Nexus不会将其缓存到本地存储库中.

我已经在本节中搜索了答案,而且无法回答这个问题.

这就是我做的......

我正在使用settings.xml:

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://THE_URL:8080/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <servers>
    <server>
      <id>admin</id>
      <username>user</username>
      <password>password</password>
    </server>
  </servers>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>

        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>

      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

</settings>
Run Code Online (Sandbox Code Playgroud)

我还为我正在使用的所有第三方存储库创建了代理存储库,并将其添加到NEXUS PUBLIC GROUP.

接下来,我运行命令:

mvn clean install
Run Code Online (Sandbox Code Playgroud)

并得到以下错误:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building shlang 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://THE_URL:8080/nexus/content/groups/public/com/shadow/shadow/1/shadow-1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.341s
[INFO] Finished at: Sun Jun 30 11:59:42 IDT 2013
[INFO] Final Memory: 6M/120M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project shlang: Could not resolve dependencies for project com.shadow:shlang:jar:1.0-SNAPSHOT: Failed to collect dependencies for [couchbase:couchbase-client:jar:1.1.5 (compile), com.google.code.gson:gson:pom:2.2.2 (compile), org.json:json:jar:20090211 (compile), net.sf.json-lib:json-lib:jar:jdk15:2.4 (compile), jline:jline:jar:2.10 (compile), commons-validator:commons-validator:jar:1.4.0 (compile), spy:spymemcached:jar:2.8.1 (compile), com.shadow:util:jar:1.0.1 (compile), com.shadow:monkey_schoolyard:jar:1.0.0 (compile)]: Failed to read artifact descriptor for com.shadow:util:jar:1.0.1: Could not find artifact com.shadow:shadow:pom:1 in nexus (http://THE_URL:8080/nexus/content/groups/public) -> [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/DependencyResolutionException
Run Code Online (Sandbox Code Playgroud)

本地回购的结果是它不包含任何第三方罐子.

我在这里想念什么?

Man*_*ser 8

很可能您的本地Maven存储库具有无法缓存组件的事实.您可以强制Maven使用-U标志检查快照版本的更新以及以前未找到的版本是否存在.

所以跑

mvn clean install -U
Run Code Online (Sandbox Code Playgroud)

有时,如果事情真的很奇怪,它可以帮助完全删除本地存储库中的相应文件夹结构.所以在你的例子中

rm -rf ~/.m2/repository/com/shadow/
Run Code Online (Sandbox Code Playgroud)


swe*_*tfa 5

如果Manfred的解决方案对您不起作用,那么Nexus可能会尝试解决该问题。

如果您使用的是浏览器,则可以检查Nexus实际在做什么,以找到所需的工件。

在工件的路径后附加-描述到Nexus存储库的url。

例如Nexus储存库公共储存库URL:http://my.nexus.server.address:8081 / nexus / content / groups / public /

获取工件

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.5</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

上述工件的路径为:org / slf4j / slf4j-api / 1.7.5 / slf4j-api-1.7.5.jar

因此,要检查的完整网址

http://my.nexus.server.address:8081 / nexus / content / groups / public / org / slf4j / slf4j-api / 1.7.5 / slf4j-api-1.7.5.jar?描述

然后,此过程将按照指定存储库的顺序遍历在“公共存储库”组下配置的存储库列表,以指示为什么存储库无法提供所请求的工件。

大多数原因都是不言自明的,可以忽略。

可能感兴趣的一个原因是,当仍然为存储库找不到错误时仍在缓存该错误时。

这表示Nexus在某个时候尝试检索工件并未能找到它。

此状态似乎已在Nexus中缓存,因此清除缓存的最快方法是重启Nexus