【问题标题】:Sonatype Nexus server on localhost doesn't cache artifacts本地主机上的 Sonatype Nexus 服务器不缓存工件
【发布时间】:2015-09-09 15:19:22
【问题描述】:

我已经在我的 64 位本地主机 Windows 上安装了 nexus-2.11。我通过 ant-tasks 在 Eclipse 中的 build.xml 中运行 mvn。我已将.m2/settings.xml中的nexus服务器设置为主镜像:

<mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>

当运行mvn 命令时,依赖关系被解析,并且在日志中显示它们是从 Nexus 服务器下载的。问题在于 Nexus 缓存:Nexus 不缓存任何内容。我的意思是sonatype-work 文件夹是空的,所有工件都在.m2 中。

登录管理面板,我可以看到工件的完整索引,但 sonatype-work 内没有 jar 文件或元数据。 (下载完所有工件后,我想把sonatype-work的内容放到因为安全原因离线的主服务器中。)

这可能是什么原因造成的?

【问题讨论】:

  • Nexus 进程(我相信是 Jetty)是否拥有文件夹 sonatype-work 的写入权限?
  • 是的。我还尝试以管理员身份运行它,甚至移动到另一个驱动器。

标签: maven nexus


【解决方案1】:

您是否在settings.xmlprofiles 部分插入了类似的内容?

    <profile>
        <id>company-nexus</id>
        <repositories>
            <repository>
                <id>central</id>
                <url>http://central</url>  <!-- use a not existing 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>

这会导致 maven 查看 mirror 定义。

【讨论】:

  • 是的,我做到了。运行命令时会显示像 Downloading: http://localhost:8081/nexus/content/groups/public/... 这样的消息。所以,它确实查看镜像定义。
【解决方案2】:

根据sonatype-work/README.txt,我将环境变量PLEXUS_NEXUS_WORK设置为sonatype-work的路径,然后Nexus开始缓存到工作文件夹中。

可以使用环境变量覆盖各个工作文件夹的位置。例如,可以使用 PLEXUS_NEXUS_WORK 定义 Nexus 工作位置。如果未定义,则使用此默认值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-14
    • 1970-01-01
    • 2022-07-28
    • 2013-09-28
    • 2011-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多