大数据开发的 Maven 配置

Maven 配置多个镜像不生效

你可能试过,在 settings.xml 配置文件中配置多个镜像库来实现:依赖如果不在第一个镜像库,那么就去第二个镜像仓库下载,依次类推…

Maven – Guide to Mirror Settings (apache.org)
在上面的 Maven 文档中已经申明,只能配置最多一个镜像仓库,Maven 是实现不了你想要的需求的,你可能看到其它博客千篇一律介绍配置了多个镜像仓库,然后使用了相同的 mirrotOf ,这只能实现 如果第一个镜像仓库无法连接,那么就使用第二个镜像仓库!!!

在这种情况下,只能配置多个远程仓库来实现该需求

在这里插入图片描述

大数据开发的 Maven 配置

默认使用 JDK1.8 为环境语言版本

使用阿里云的镜像仓库,如果阿里云镜像仓库无法连接就是用远程中心仓库

增加了大数据常用的远程仓库 CDHJBOSS

<?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">
  
    <localRepository>/Users/kylewhite/dev/apache-repository</localRepository>

    <usePluginRegistry>false</usePluginRegistry>

    <offline>false</offline>
    <mirrors>
        <mirror>
            <id>alimaven</id>
            <mirrorOf>central</mirrorOf>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </mirror>
        <mirror>
            <id>repo2</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://repo2.maven.org/maven2/</url>
        </mirror>
    </mirrors>
<profiles>
    <profile>
        <id>jdk8</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <jdk>1.8</jdk>
        </activation>
        <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
        </properties>
    </profile>
    <profile>
        <!-- ID 必须唯一 -->
        <id>cloudera</id>
        <repositories>
            <repository>
                <!-- ID 必须唯一 -->
                <id>cloudera_repo</id>
                <!-- 仓库的 URL 地址 -->
                <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </repository>
        </repositories>
    </profile>
    <profile>
        <id>jboss</id>
        <repositories>
            <repository>
                <id>jboss_repo</id>
                <url>http://repository.jboss.com/nexus/content/groups/public</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </repository>
        </repositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>cloudera</activeProfile>
    <activeProfile>jboss</activeProfile>
</activeProfiles>
    
</settings>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值