知乐空间

阿里云镜像站怎么下载

单独配置华为云 mirror

准备工作使用前请确保您已安装JDK及Maven。如果您尚未安装,可以点击下面链接下载安装:JDK官网下载地址:
https://www.oracle.com/technetwork/java/javase/downloads/index.htmlMaven加速地址:https://repo.huaweicloud.com/apache/maven/maven-3/

使用说明点击此处 下载settings.xml文件,覆盖/conf/settings.xml文件即可。如果您不想覆盖配置文件,可以手动在settings.xml文件中的mirrors节点中添加如下内容:


    huaweicloud
    *
    https://repo.huaweicloud.com/repository/maven/

相关网址Maven官方地址:
https://maven.apache.orgMaven搜索地址:http://mvnrepository.com

单独配置华为私有库依赖

1.在mirrors节点中添加如下配置:(可选,使用华为开源镜像站加速下载开源组件)

    
        z_mirrors
        *,!releases,!snapshots
        https://repo.huaweicloud.com/repository/maven/
    

2.在servers节点中添加如下配置:(password从下载的settings.xml文件中获取)


    
        releases
        088dbeef3980f4050f6fc007779eab60_088dbef03980f2d21f98c007dcbde04f
        ************
    
    
        snapshots
        088dbeef3980f4050f6fc007779eab60_088dbef03980f2d21f98c007dcbde04f
        ************
    

3.在profiles节点中添加如下配置

    
        MyProfile
        
            
                releases
                https://devrepo.devcloud.cn-north-4.huaweicloud.com/07/nexus/content/repositories/088dbeef3980f4050f6fc007779eab60_1_0/
                
                    true
                
                
                    false
                
            
            
                snapshots
                https://devrepo.devcloud.cn-north-4.huaweicloud.com/07/nexus/content/repositories/088dbeef3980f4050f6fc007779eab60_2_0/
                
                    false
                
                
                    true
                
            
        
    

单独配置阿里云 mirror

打开maven的配置文件(windows机器一般在maven安装目录的conf/settings.xml),在标签中添加mirror子节点:


    aliyunmaven
    *
    阿里云公共仓库
    https://maven.aliyun.com/repository/public

如果想使用其它代理仓库,可在节点中加入对应的仓库使用地址。以使用spring代理仓为例:


    spring
    https://maven.aliyun.com/repository/spring
    
        true
    
    
        true
    

单独配置阿里云效私有库依赖

1.在mirrors节点中添加如下配置:(可选,使用阿里开源镜像站加速下载开源组件)

        
            mirror
            !rdc-releases,!rdc-snapshots
            https://maven.aliyun.com/repository/public
        
  1. 在settings.xml中添加认证信息
    在Maven的的默认settings.xml中找到servers的部分,添加一个server配置如下。

    
        rdc-releases
        ***
        ******
    
    
        rdc-snapshots
        ***
        ******
    

3.在profiles节点添加如下配置, 其中 repository 是顺序搜索下载包的.


            rdc-private-repo
            
                
                    rdc-releases
                    https://repo.rdc.aliyun.com/repository/78947-release-CfzLQ7/
                    
                        true
                    
                    
                        false
                    
                
                
                    rdc-snapshots
                    https://repo.rdc.aliyun.com/repository/78947-snapshot-XtuBsZ/
                    
                        false
                    
                    
                        true
                    
                
            
            
                
                    rdc-releases
                    https://repo.rdc.aliyun.com/repository/78947-release-CfzLQ7/
                    
                        true
                    
                    
                        false
                    
                
                
                    rdc-snapshots
                    https://repo.rdc.aliyun.com/repository/78947-snapshot-XtuBsZ/
                    
                        false
                    
                    
                        true
                    
                
            
        
  1. 制品上传配置
    配置好了settings.xml后,在代码库根目录下的pom.xml加入以下配置:


    
        rdc-releases
        https://repo.rdc.aliyun.com/repository/78947-release-CfzLQ7/
    
    
        rdc-snapshots
        https://repo.rdc.aliyun.com/repository/78947-snapshot-XtuBsZ/
    

然后运行以下命令即可将制品推送到私有仓库中:

$ mvn clean deploy -DskipTests

Maven中-DskipTests和-Dmaven.test.skip=true的区别在使用mvn package进行编译、打包时,Maven会执行src/test/java中的JUnit测试用例,有时为了跳过测试,会使用参数-DskipTests和-Dmaven.test.skip=true,这两个参数的主要区别是:

-DskipTests,不执行测试用例,但编译测试用例类生成相应的class文件至target/test-classes下。-Dmaven.test.skip=true,不执行测试用例,也不编译测试用例类。

关于 mirror 的说明

虽然mirrors可以配置多个子节点,但是它只会使用其中的一个节点,即默认情况下配置多个mirror的情况下,只有第一个生效,只有当前一个mirror无法连接的时候,才会去找后一个;而我们想要的效果是:当a.jar在第一个mirror中不存在的时候,maven会去第二个mirror中查询下载,但是maven不会这样做!

关于 properties 的说明

properties作用:对应profile的扩展属性列表。maven属性和ant中的属性一样,可以用来存放一些值。这些值可以在pom.xml中的任何地方使用标记${X}来使用,这里X是指属性的名称。属性有五种不同的形式,并且都能在settings.xml文件中访问。




  ${user.home}/our-project

配置了 阿里和华为云配置的综合案例

<?xml version="1.0" encoding="UTF-8"?>

    
    
    
        
        
        
            huawei-rdc-repository
            ****yourname***
            ****yourpassword******
        
        
            huawei-rdc-snapshots-repository
            ****yourname***
            ****yourpassword******
        
        
        
            aliyun-rdc-repository
            ****yourname***
            ****yourpassword******
        
        
            aliyun-rdc-snapshots-repository
            ****yourname***
            ****yourpassword******
        
        
        
            poly-rdc-repository
            admin
            ncl@1234
        
    
    
        
            huaweiMirror
            华为云公共仓库
            central
            https://repo.huaweicloud.com/repository/maven/
        
        
            aliyunMirror
            阿里云公共仓库
            central
            https://maven.aliyun.com/repository/public
        
    
    
        
            default-profile
            
                https://maven.aliyun.com/nexus/content/groups/public
            
            
                
                    central
                    ${my.repository.url}
                    
                        true
                    
                    
                        false
                    
                
                
                    snapshots
                    ${my.repository.url}
                    
                        false
                    
                    
                        true
                    
                
            
            
                
                    central
                    ${my.repository.url}
                    
                        true
                    
                    
                        false
                    
                
                
                    snapshots
                    ${my.repository.url}
                    
                        false
                    
                    
                        true
                    
                
            
        
        
            huawei-profile
            
                https://devrepo.devcloud.cn-north-4.huaweicloud.com/07/nexus/content/repositories/088dbeef3980f4050f6fc007779eab60_1_0/
                https://devrepo.devcloud.cn-north-4.huaweicloud.com/07/nexus/content/repositories/088dbeef3980f4050f6fc007779eab60_2_0/
            
            
                
                    huawei-rdc-repository
                    ${my.releases.url}
                    
                        true
                    
                    
                        false
                    
                
                
                    huawei-rdc-snapshots-repository
                    ${my.snapshots.url}
                    
                        false
                    
                    
                        true
                    
                
            
            
                
                    huawei-rdc-repository
                    ${my.releases.url}
                    
                        true
                    
                    
                        false
                    
                
                
                    huawei-rdc-snapshots-repository
                    ${my.snapshots.url}
                    
                        false
                    
                    
                        true
                    
                
            
        
        
            aliyun-profile
            
                https://repo.rdc.aliyun.com/repository/78947-release-CfzLQ7/
                https://repo.rdc.aliyun.com/repository/78947-snapshot-XtuBsZ/
            
            
                
                    aliyun-rdc-repository
                    ${my.releases.url}
                    
                        true
                    
                    
                        false
                    
                
                
                    aliyun-rdc-snapshots-repository
                    ${my.snapshots.url}
                    
                        false
                    
                    
                        true
                    
                
            
            
                
                    aliyun-rdc-repository
                    ${my.releases.url}
                    
                        true
                    
                    
                        false
                    
                
                
                    aliyun-rdc-snapshots-repository
                    ${my.snapshots.url}
                    
                        false
                    
                    
                        true
                    
                
            
        
        
            poly-profile
            
                
            
            
                
            
        
    
    
        default-profile
        
        aliyun-profile
        
    

相关地址

https://mirrors.huaweicloud.com/

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请发送邮件至 ZLME@ZLME.COM 举报,一经查实,立刻删除。

留言与评论(共有 0 条评论)
验证码: