当前位置: 首页 > 知识库问答 >
问题:

来自内部和中央存储库的Maven依赖项

彭烨熠
2023-03-14

我在Maven有一个内部的Nexus存储库,其中部署了一些插件。在nexus存储库中存在一些不存在的依赖jar文件。是否可以将maven配置为在内部存储库中搜索依赖jar文件,如果在maven中心存储库中不存在搜索。

使现代化

做出了与JimHawkins回答中类似的配置。但我仍然认为它只在nexus内部存储库中查找依赖项。以下是它打印的一些debus Messes:

[DEBUG] Using mirror Nexus (<internal-repo>) for central (repo1.maven.org/maven2).
[DEBUG] Using mirror Nexus (<internal-repo>) for Nexus (my.repository.com/repo/path)
[ERROR] Unresolveable build extension: Plugin <plugin-name> or one of its dependencies
    could not be resolved: Failure to find org.co dehaus.plexus:plexus-utils:jar:1.1 in <internal-repo>
    was cached in the local repository

共有1个答案

卫博
2023-03-14

如果您修改个人maven设置。xml(位于

在maven从Nexus获取依赖项之后,每个依赖项也存储在工作站上的本地maven存储库中

您可以告诉Nexus不仅在maven中央存储库中,而且在其他公共存储库(如JBoss公共存储库)中搜索新的工件。

另请参见:Maven配置
设置中使用这些设置。xml

<mirrors>
    <!--
        mirror | Specifies a repository mirror site to use instead of a
        given repository. The repository that | this mirror serves has an ID
        that matches the mirrorOf element of this mirror. IDs are used | for
        inheritance and direct lookup purposes, and must be unique across
        the set of mirrors. | <mirror> <id>mirrorId</id>
        <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this
        Mirror.</name> <url>http://my.repository.com/repo/path</url>
        </mirror>
    -->

    <mirror>
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://your.internal-nexus.com/content/groups/public</url>
    </mirror>

</mirrors>

<profiles>    
    <profile>
        <id>nexus</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>

        <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>
    <activeProfile>nexus</activeProfile>
</activeProfiles>

 类似资料:
  • 问题内容: 我公司的政策不支持自动下载的工件(必须经过批准),因此,要使用Maven,我需要禁用对Maven中央存储库的访问。 换句话说,我不希望Maven尝试从Central下载任何内容。 我知道如何配置本地存储库(是否联网),我的想法是使用“受祝福的”计算机来更新本地存储库。 PS:我可以在代理/网络级别阻止请求,但是我在问如何使用Maven的配置来完成请求。 UPDATE 我终于想出了怎么做

  • 由于“需要HTTPS”错误,我最近在构建项目时遇到了问题。这个问题通过如下所述修改我的pom.xml得到了解决,添加了以下内容: 然而,为我的每个项目更新每个pom.xml是一件麻烦的事。 我尝试将相同的代码片段添加到我的settings.xml,但没有成功。 我知道更新版本的Maven解决了这个问题。然而,由于工作限制,我无法更新我的环境。 我目前已经安装了Java8和Maven,由Netbea

  • 我想把公司artifactory添加到Zeppelin spark解释器中,并尝试使用这份文档。 因此,我们的artifactory的URL看起来像 访问不限于特定的用户,工件可以从我的机器和运行Zepplin的机器下载(我用curl尝试了这一点)。 设置解释器“spark.spark”的属性时出错:找不到项目com.feedvisor.dataplatform:data-platform-sch

  • Maven只是看不到这些存储库,直到我从中删除。我还尝试将其他存储库镜像到Nexus,但没有成功:Maven仍然只使用中央存储库。 我做错了什么?

  • 我运行一个开源库,正在考虑让它完全接受Maven并将其上传到中央存储库,以便人们可以轻松地将其添加到他们的项目中。 问题在于,它依赖于几个较旧的库,这些库在任何 Maven 存储库中都不存在。目前,这意味着pom文件必须使用依赖项范围。我还阅读了有关为项目创建本地存储库以安装第三方库的信息。 但是,我的印象是,当我将库部署到 Maven 存储库时,这两种方法都不能很好地工作。也就是说,如果它依赖于

  • 我试图理解maven是如何从存储库中下载二进制文件的。 例如,我的项目有以下依赖关系: 现在,这些二进制文件出现在http://mvnrepository.com/. 在pom.xml中,我们有