首页 文章

Nexus没有缓存maven中央插件

提问于
浏览
10

我使用Maven 3.0.4和Nexus 2.0.6 . 我已将settings.xml设置为使用单个存储库的Nexus指令 . 当maven尝试运行maven -U clean时,我收到以下错误 .

[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its d
ependencies could not be resolved: Failed to read artifact descriptor for org.ap
ache.maven.plugins:maven-clean-plugin:jar:2.4.1: Could not find artifact org.apa
che.maven.plugins:maven-clean-plugin:pom:2.4.1 in nexus (http://localhost:8081/n
exus/content/groups/public) -> [Help 1]

如果我从设置中删除nexus镜像并直接进入maven central命令有效 . nexus中maven repo的设置显示它正在服务中,并且它位于公共组(最后列出)中 .

我不是支持访问互联网的代理人 .

这是我的settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<offline>false</offline>
<mirrors>
    <mirror>
        <!--This sends everything else to /public -->
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
</mirrors>
<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>
    <profile>
        <id>maven-central</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://repo1.maven.org/maven2/</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <url>http://repo1.maven.org/maven2/</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>

3 回答

  • 3

    确保正确配置了 Central 代理存储库,并且代理的URL为 http://repo1.maven.org/maven2/ . 检查您是否可以在存储库的URL中看到缓存的工件,应该是 http://localhost:8081/nexus/content/repositories/central/org/apache/maven/plugins/maven-clean-plugin/2.4.0/maven-clean-plugin-2.4.1.pom .

    确保您有一个中央代理, http://localhost:8081/nexus/content/repositories/central/ 中是否列出了任何内容 .

    如果您位于代理后面,则可以在“管理” - >“Nexus”窗格的“默认HTTP代理设置(可选)”部分下配置代理 .

    然后,确保 Public Repositories 组存储库配置为在其包含的存储库列表中包含 Central 存储库 .

    如果到目前为止一切正常,请检查日志,也许那里有一条有用的消息 .

  • 0

    尝试直接通过网络浏览器下载:

    http://localhost:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
    

    如果这不起作用,请检查sonatype-work / nexus / logs / nexus.log文件以获取有关失败的更多信息 .

  • 5

    我有与OP相同的症状(Nexus没有镜像人工制品)并发现它是由路由定义引起的 .

    例如,您在Maven Central中有一个工件 org.blabla:blabla-api:1.0 . 但是,您已设置匹配 .*/org/blabla/.* 的路由,该路由强制任何匹配的请求仅在代理存储库中查找 blabla-public ...但遗憾的是 blabla-public 不包含该特定工件 .

    解决方案:更新路由以将Central添加到路由使用的repos列表,或删除路由 .

    (这可能不是OP的原因,但我发布它以防万一它可以帮助任何其他访问者 . )

相关问题