Maven 配置远程仓库

最近要用到一个包:spark-1.6.0-cdh5.8.2,在https://mvnrepository.com网站上搜到该包的pom.xml语句。但是看到下面有这样一句话:

note

该包在图中所述repository中。因此要添加该repositorymvn远程数据仓库,才能获取到该依赖包。

下面给出添加远程仓库的方法:
mavenconf/settings.xml文件下,找到<profiles>标签下添加以下配置:

    <profile>  
      <id>cdh</id>  
      <repositories>    
        <repository>    
          <id>hadoop-cdh</id>    
          <name>cloudera</name>    
          <url>https://repository.cloudera.com/content/repositories/releases/</url>    
          <releases>    
            <enabled>true</enabled>    
          </releases>    
          <snapshots>    
            <enabled>false</enabled>    
          </snapshots>    
        </repository>    
      </repositories>       
    </profile>  

<profiles>标签下添加以下配置以激活该远程仓库,使其变得可用。

  <activeProfiles>  
    <activeProfile>cdh</activeProfile>  
  </activeProfiles>  

添加了以上配置,即可从该远程库中下载所需jar包。

另外,如果在IntelliJ Idea中还是没有找到该依赖包,一定要记得配置IDEA中所用maven路径为自己配置的maven路径。

参考:
http://elim.iteye.com/blog/1900568

原文地址:https://www.cnblogs.com/eva_sj/p/6172243.html