Java-Maven(八):IDEA使用本地maven,并配置远程中央仓库

1)maven安装

一般我们从github、码云(https://gitee.com)上获取代码后,实际上我们并没有一个版本管理工具来用来获取(get)、提交(commit and push)代码的工具,因此需要使用一个代码提交管理工具,maven是这类工具中比较好的工具。

声明:maven安装请参考:《Java-Maven(一):Maven的简介与安装


备注:本地已经安装好了maven,安装目录为:D:\Work\Java\apache-maven-3.5.0-bin\apache-maven-3.5.0

2)给idea从github、码云等获取到的项目绑定 maven:

3)修改pom.xml,添加资源库管理插件配置(可忽略):

1   <pluginRepositories>
2     <pluginRepository>
3       <id>scala-tools.org</id>
4       <name>Scala-Tools Maven2 Repository</name>
5       <url>http://scala-tools.org/repo-releases</url>
6     </pluginRepository>
7   </pluginRepositories>

4)配置远程中央仓库:

一般情况下可以配置为国外的远程中央仓库,但是在国内从国外远程中央仓库下载jar包的速度比较差。如果国内的话,建议使用阿里的远程中央仓库(下载速度快)。配置阿里的远程中央仓库有两种方案:
配置方式一:
conf\setting.xml

1   <mirrors>
2     <mirror>
3       <id>alimaven</id>
4       <name>aliyun maven</name>
5       <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
6       <mirrorOf>central</mirrorOf>        
7     </mirror>     
8   </mirrors>

配置方式二:

在项目的pom.xml中配置:

 1     <repositories>
 2         <repository>
 3             <id>sonatype-nexus-snapshots</id>
 4             <name>Sonatype Nexus Snapshots</name>
 5             <url>http://maven.aliyun.com/nexus/content/groups/public</url>
 6             <releases>
 7                 <enabled>false</enabled>
 8             </releases>
 9             <snapshots>
10                 <enabled>true</enabled>
11             </snapshots>
12         </repository>
13     </repositories>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值