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

1)maven安装

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

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

Java-Maven(八):IDEA使用本地maven,并配置远程中央仓库_第1张图片
备注:本地已经安装好了maven,安装目录为:D:\Work\Java\apache-maven-3.5.0-bin\apache-maven-3.5.0

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

Java-Maven(八):IDEA使用本地maven,并配置远程中央仓库_第2张图片

Java-Maven(八):IDEA使用本地maven,并配置远程中央仓库_第3张图片

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

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

4)配置远程中央仓库:

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

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

配置方式二:

在项目的pom.xml中配置:

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

 

你可能感兴趣的:(Java-Maven(八):IDEA使用本地maven,并配置远程中央仓库)