淺談Maven的安裝及修改為阿里云下載依賴
使用JAVA工程管理越來越多的jar包,擔(dān)心導(dǎo)錯(cuò)了,多導(dǎo)了,漏導(dǎo)了怎么辦?
換一個(gè)IDE項(xiàng)目后項(xiàng)目會(huì)不會(huì)出一堆BUG,看的頭皮發(fā)麻?
自己寫的代碼放在別人的機(jī)器上運(yùn)行會(huì)不會(huì)出問題?
Maven的強(qiáng)大毋庸置疑,當(dāng)使用Maven后以上這些都不是問題,但是配置maven是一件耐心的事情,基本步驟總結(jié)如下:
一、下載
http://maven.apache.org/download.cgi
也可以直接在eclipse工具中下載,點(diǎn)擊eclipse菜單欄Help->Eclipse Marketplace搜索關(guān)鍵字maven到插件Maven Integration for Eclipse 并點(diǎn)擊安裝即可
架構(gòu)Maven工作環(huán)境(配置環(huán)境變量)
新建:MAVEN_HOME
路徑(例如):D:\360Downloads\tools\marven3.5\apache-maven-3.5.0
添加到path配置文件中:;%MAVEN_HOME%\bin;
二、配置好后驗(yàn)證
輸入mvn -version
成功后會(huì)有如以下提示:
Microsoft Windows [版本 6.1.7601]
版權(quán)所有 (c) 2009 Microsoft Corporation。保留所有權(quán)利。
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"
三、修改默認(rèn)下載地址,默認(rèn)下載地址在C盤中如下:
C:\Users\Administrator\.m2
建議換一個(gè)地址,防止系統(tǒng)變慢,重裝系統(tǒng)也不會(huì)影響。
如:D:\eee\1701javaee_2\maveninport_aliyun\.m2
四、將安裝路徑下的apache-maven-3.5.0\conf\settings.xml文件復(fù)制一份到新地址的.m2目錄下面(與repository在同一目錄)。
五、打開eclipse將Maven工程添加到eclipse工具中。
window->preferences->maven->installations->add->maven安裝路徑。
六、打開settings.xml,修改如下2個(gè)地方的內(nèi)容:
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、此處為修改為從阿里云服務(wù)器上下載依賴,強(qiáng)烈建議更換,下載速度會(huì)快很多,在文件第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> </mirrors>
完成后重啟eclipse.
以上這篇淺談Maven的安裝及修改為阿里云下載依賴就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Java Fluent Mybatis 分頁查詢與sql日志輸出詳解流程篇
Java中常用的ORM框架主要是mybatis, hibernate, JPA等框架。國內(nèi)又以Mybatis用的多,基于mybatis上的增強(qiáng)框架,又有mybatis plus和TK mybatis等。今天我們介紹一個(gè)新的mybatis增強(qiáng)框架 fluent mybatis關(guān)于分頁查詢、sql日志輸出流程2021-10-10
Maven多模塊及version修改的實(shí)現(xiàn)方法
這篇文章主要介紹了Maven多模塊及version修改的實(shí)現(xiàn)方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-06-06
如何用Java將數(shù)據(jù)庫的數(shù)據(jù)生成pdf返回給前端用戶下載
本文詳細(xì)介紹了使用SpringBoot、iText庫、MyBatis等技術(shù)從數(shù)據(jù)庫中選取數(shù)據(jù)并生成PDF文件的后端處理流程,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-09-09
SpringBoot2.0整合Shiro框架實(shí)現(xiàn)用戶權(quán)限管理的示例
這篇文章主要介紹了SpringBoot2.0整合Shiro框架實(shí)現(xiàn)用戶權(quán)限管理的示例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-08-08
springboot+feign+Hystrix整合(親測(cè)有效)
本文主要介紹了springboot+feign+Hystrix整合,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-11-11
Java實(shí)現(xiàn)雙鏈表互相交換任意兩個(gè)節(jié)點(diǎn)的方法示例
這篇文章主要介紹了Java實(shí)現(xiàn)雙鏈表互相交換任意兩個(gè)節(jié)點(diǎn)的方法,簡單講述了雙鏈表的概念,并結(jié)合實(shí)例形式給出了java雙鏈表實(shí)現(xiàn)任意兩個(gè)節(jié)點(diǎn)交換的操作技巧,需要的朋友可以參考下2017-11-11

