自建 Nexus OSS 私库无法下载Snapshot版本依赖的问题

自建 Nexus OSS 私库无法下载Snapshot版本依赖的问题

无法从Nexus OSS中下载对应的SNAPSHOT版依赖,但该依赖确实存在于仓库中,而获取Release版依赖却又正常。

错误信息:

             ERROR : Could not find artifact com.example:example:jar:1.0-SNAPSHOT

原因:

     从Release仓库下载Snapshot版依赖包,这当然找不到啦,我的原因是没有在Maven的setting.xml

     配置文件中指明那些仓库可下载release依赖、哪些仓库可下载snapshot依赖。

解决:

          在setting.xml中的节点添加一个profile:

Xml代码

<profile>  
    <id>nexus</id>  
    <!--Enable snapshots for the built in central repo to direct -->  
    <activation>  
        <activeByDefault>true</activeByDefault>  
    </activation>  
    <!--all requests to nexus via the mirror -->  
    <repositories>  
        <repository>  
            <id>maven-releases</id>  
            <url>http://xxxx.com:8081/content/repositories/releases/</url>  
            <releases>  
                <enabled>true</enabled>  
            </releases>  
            <snapshots>  
                <enabled>false</enabled>  
            </snapshots>  
        </repository>  
        <repository>  
            <id>maven-snapshots</id>  
            <url>http://xxxx.com:8081/content/repositories/snapshots/</url>  
            <releases>  
                <enabled>false</enabled>  
            </releases>  
            <snapshots>  
                <enabled>true</enabled>  
            </snapshots>  
        </repository>  
    </repositories>  
</profile>  

版权声明:本文为adminmy原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。