使用JAVA工程管理越来越多的jar包,担心导错了,多导了,漏导了怎么办?

换一个IDE项目后项目会不会出一堆BUG,看的头皮发麻?

自己写的代码放在别人的机器上运行会不会出问题?

Maven的强大毋庸置疑,当使用Maven后以上这些都不是问题,但是配置maven是一件耐心的事情,基本步骤总结如下:

一、下载
http://maven.apache.org/download.cgi
也可以直接在eclipse工具中下载,点击eclipse菜单栏Help->Eclipse Marketplace搜索关键字maven到插件Maven Integration for Eclipse 并点击安装即可

架构Maven工作环境(配置环境变量)
新建:MAVEN_HOME
路径(例如):D:\360Downloads\tools\marven3.5\apache-maven-3.5.0
添加到path配置文件中:;%MAVEN_HOME%\bin;
二、配置好后验证
输入mvn -version
成功后会有如以下提示:

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\Administrator>mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:0
6+08:00)
Maven home: D:\360Downloads\tools\marven3.5\apache-maven-3.5.0-bin\apache-maven-
3.5.0\bin\..
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: D:\Program Files\Java\jdk1.8.0_121\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

三、修改默认下载地址,默认下载地址在C盘中如下:

C:\Users\Administrator\.m2
建议换一个地址,防止系统变慢,重装系统也不会影响。
如:D:\eee\1701javaee_2\maveninport_aliyun\.m2

四、将安装路径下的apache-maven-3.5.0\conf\settings.xml文件复制一份到新地址的.m2目录下面(与repository在同一目录)。

五、打开eclipse将Maven工程添加到eclipse工具中。
window->preferences->maven->installations->add->maven安装路径。

六、打开settings.xml,修改如下2个地方的内容:
1、此处为存放下载依赖存放地方,在文件第53行:

原始文件:
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
修改后的文件:
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>D:\eee\1701javaee_2\maveninport_aliyun\.m2\repository</localRepository>

2、此处为修改为从阿里云服务器上下载依赖,强烈建议更换,下载速度会快很多,在文件第160行

原始文件:
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
</mirrors>

修改后的文件:
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->

<!-- 阿里云镜像 下载配置 -->
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

<!-- 另一个备用模板 -->

<!-- <mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>-->

</mirrors>

完成后重启eclipse.

Maven的安装及修改为阿里云下载依赖的更多相关文章

  1. 【maven】Maven将中央仓库修改为阿里云的仓库地址

    <mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexu ...

  2. Maven将中央仓库修改为阿里云的仓库地址

    <mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexu ...

  3. 1.docker介绍、命令、容器、镜像、数据卷、Dockerfile、常用软件安装、推送阿里云

    一.docker介绍 1.docker是什么 一款产品从开发到上线,从操作系统,到运行环境,再到应用配置.作为开发+运维之间的协作我们需要关心很多东西,这也是很多互联网公司都不得不面对的问题,特别是各 ...

  4. MikroTik RouterOS安装chr授权到阿里云虚拟机(转)

    CHR介绍 CHR(Cloud Hosted Router) 是用于在虚拟机上运行的 RouterOS 版本,它支持x86_64架构,支持大多数流行的虚拟化技术,如 VMWare, Hyper-V, ...

  5. maven 亲测可用国内镜像 阿里云(20170123)

    来源于:http://www.jianshu.com/p/4d5bb95b56c5 http://blog.csdn.net/qq_27093465/article/details/52982484 ...

  6. gitlab安装、配置与阿里云产品集成

    https://www.ilanni.com/?p=12819 一.gitlab安装与部署 gitlab的安装可以分为源码安装和通过安装包进行安装,要是按照我以前的写作习惯的话,我也会把源码安装在本文 ...

  7. nginx安装与fastdfs配置--阿里云

    上一篇文章:fastDFS 一二事 - 简易服务器搭建之--阿里云 做了fastDFS的服务安装和配置,接下来我们来看nginx的安装 第一步:安装nginx需要安装的一些环境: 1.例如: yum ...

  8. 在Maven项目中,指定使用阿里云仓库下载jar包

    Maven项目中,在pom.xml的</project>标签之前加入一下标签,指定使用阿里云仓库下载jar包. <!-- 使用aliyun maven --> <repo ...

  9. Maven项目添加阿里云HBase依赖之后第一行才出现红叉报错“Missing artifact jdk.tools:jdk.tools:jar:1.6”的解决办法

    首先是从阿里云上下载了一个样例项目"hbase-demo",然后用eclipse打开,此时eclipse会去下载aliyun.hbase依赖. 等待一段时间后,pom.xml却报错 ...

随机推荐

  1. 图论&搜索:K短路-启发式搜索

    判断第k短路的权值是否小于T 直接把队友的代码拿过来了,一定很经典 #include <iostream> #include <queue> #include <cstr ...

  2. CF767 A. Snacktower 暴力

    LINK 题意:给出一个序列,如果存的数满足连续递减(第一个必须为n)则输出否则输出空行,并暂存当前数 思路:直接暴力不可行,由于待输出的数的个数满足单调性可以稍微优化,即从上一回输出的最小一个数开始 ...

  3. King's Sanctuary(简单几何)

    King's Sanctuary Time Limit: 1000 ms Memory Limit: 65535 kB Solved: 111 Tried: 840 Submit Status Bes ...

  4. 【洛谷】3375 KMP字符串匹配

    [算法]KMP [题解][算法]字符串 #include<cstdio> #include<algorithm> #include<cstring> using n ...

  5. Java 9 中的 9 个新特性

    Java 8 发布三年多之后,java9已经发布了 . 你可能已经听说过 Java 9 的模块系统,但是这个新版本还有许多其它的更新. 这里有九个令人兴奋的新功能将与 Java 9 一起发布.   1 ...

  6. Sublime text 2/3 SVN插件及使用方法

    Sublime Text是前端利器,作为前端的盆友们已经再熟悉不过了,在项目中经常使用SVN,每次都要切换提交,很麻烦,有了这个SVN插件就很方便了,使用快捷方式提交,更新. Sublime Text ...

  7. Python中单引号,双引号,三引号

    1.单引号与双引号的区别 s1=‘let‘s go’(明显我们是想用单引号表示let’s go这个字符串的,但是python只知道用‘’来表示字符串,所以python就把字符串中的‘字符当成单引号处理 ...

  8. php中的转义函数

    <?php parse_url 解析URL, 返回各组成部分 urlencode/urldecode url编码/解码 htmlentities 将字符串转化为html实体 htmlentiti ...

  9. 正排索引(forward index)与倒排索引(inverted index) (转)

    一.正排索引(前向索引) 正排索引也称为"前向索引".它是创建倒排索引的基础,具有以下字段. (1)LocalId字段(表中简称"Lid"):表示一个文档的局部 ...

  10. 20165301 预备作业二:学习基础和C语言基础调查

    <做中学>读后感及C语言学习调查 读<做中学>有感 娄老师在文章中多次提到「做中学(Learning By Doing)」的概念,并通过娄老师自己的减肥经历.五笔练习经历.乒乓 ...