You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将EmergyaPub仓库添加至Maven settings.xml解决依赖缺失

解决Maven找不到迁移至EmergyaPub仓库构件的配置方案

你的问题核心在于现有settings.xml中的镜像配置用了<mirrorOf>*</mirrorOf>,会将所有仓库请求转发到公司内部的maven-group仓库,但该仓库没有迁移后的目标构件。之前添加的镜像配置因为mirrorOf指定的dummy不存在,所以完全没生效。

以下是两种可行的配置方案:

方案一:添加自定义仓库Profile并排除镜像代理

修改你的settings.xml,添加包含EmergyaPub仓库的Profile,并调整原镜像的mirrorOf规则,避免代理该仓库的请求:

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <pluginGroups>
        <pluginGroup>org.mortbay.jetty</pluginGroup>
        <pluginGroup>org.apache.tomcat.maven</pluginGroup>
        <pluginGroup>com.frequentis.c4i.tools.maven</pluginGroup>
    </pluginGroups>

    <servers>
        <server>
            <id>nexus-snapshots</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
    </servers>

    <mirrors>
        <mirror>
            <id>central</id>
            <!-- 排除EmergyaPub仓库的代理,其他仓库仍走公司nexus -->
            <mirrorOf>*,!EmergyaPub</mirrorOf>
            <name>central</name>
            <url>http://fdirhel3-frequentis-usa:8081/repository/maven-group/</url>
            <blocked>false</blocked>
        </mirror>
    </mirrors>

    <!-- 添加包含EmergyaPub仓库的Profile -->
    <profiles>
        <profile>
            <id>emergya-repo</id>
            <repositories>
                <repository>
                    <id>EmergyaPub</id>
                    <url>http://nexus.emergya.es/nexus/content/repositories/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <!-- 如果该仓库包含Maven插件,需要添加此配置 -->
                <pluginRepository>
                    <id>EmergyaPub</id>
                    <url>http://nexus.emergya.es/nexus/content/repositories/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

    <!-- 激活该Profile,无需每次编译手动指定 -->
    <activeProfiles>
        <activeProfile>emergya-repo</activeProfile>
    </activeProfiles>
</settings>

方案二:直接修改公司maven-group仓库的配置(如果有权限)

如果你有权限操作公司内部的Nexus仓库,可以将EmergyaPub仓库添加到maven-group的仓库组中,这样所有请求仍通过公司nexus转发,无需修改本地settings.xml。

验证配置

修改完成后,执行以下命令清理本地仓库缓存并重新编译:

mvn clean install -U

内容的提问来源于stack exchange,提问作者John kerich

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 19:12:09