大数据开发的 Maven 配置
Maven 配置多个镜像不生效
你可能试过,在 settings.xml
配置文件中配置多个镜像库来实现:依赖如果不在第一个镜像库,那么就去第二个镜像仓库下载,依次类推…
Maven – Guide to Mirror Settings (apache.org)
在上面的 Maven
文档中已经申明,只能配置最多一个镜像仓库,Maven
是实现不了你想要的需求的,你可能看到其它博客千篇一律介绍配置了多个镜像仓库,然后使用了相同的 mirrotOf
,这只能实现 如果第一个镜像仓库无法连接,那么就使用第二个镜像仓库!!!
在这种情况下,只能配置多个远程仓库来实现该需求
大数据开发的 Maven 配置
默认使用 JDK1.8
为环境语言版本
使用阿里云的镜像仓库,如果阿里云镜像仓库无法连接就是用远程中心仓库
增加了大数据常用的远程仓库 CDH
和 JBOSS
<?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>