淺談Maven的安裝及修改為阿里云下載依賴
使用JAVA工程管理越來越多的jar包,擔(dān)心導(dǎo)錯了,多導(dǎo)了,漏導(dǎo)了怎么辦?
換一個IDE項目后項目會不會出一堆BUG,看的頭皮發(fā)麻?
自己寫的代碼放在別人的機(jī)器上運行會不會出問題?
Maven的強(qiáng)大毋庸置疑,當(dāng)使用Maven后以上這些都不是問題,但是配置maven是一件耐心的事情,基本步驟總結(jié)如下:
一、下載
http://maven.apache.org/download.cgi
也可以直接在eclipse工具中下載,點擊eclipse菜單欄Help->Eclipse Marketplace搜索關(guān)鍵字maven到插件Maven Integration for Eclipse 并點擊安裝即可
架構(gòu)Maven工作環(huán)境(配置環(huán)境變量)
新建:MAVEN_HOME
路徑(例如):D:\360Downloads\tools\marven3.5\apache-maven-3.5.0
添加到path配置文件中:;%MAVEN_HOME%\bin;
二、配置好后驗證
輸入mvn -version
成功后會有如以下提示:
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
建議換一個地址,防止系統(tǒng)變慢,重裝系統(tǒng)也不會影響。
如: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個地方的內(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)烈建議更換,下載速度會快很多,在文件第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)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Java應(yīng)用程序的CPU使用率飆升原因詳細(xì)分析
這篇文章主要介紹了Java應(yīng)用程序的CPU使用率飆升原因詳細(xì)分析,在 Java 中,我們使用 JVM 進(jìn)行線程調(diào)度,所以一般來說,線程的調(diào)度有兩種模式:分時調(diào)度和搶占式調(diào)度,線程和進(jìn)程在阻塞或者等待時,都不會使用 CPU 資源,需要的朋友可以參考下2024-01-01Mybatis-Plus批量添加或修改數(shù)據(jù)的3種方式總結(jié)
使用Mybatis-plus可以很方便的實現(xiàn)批量新增和批量修改,不僅比自己寫foreach遍歷方便很多,而且性能也更加優(yōu)秀,下面這篇文章主要給大家介紹了關(guān)于Mybatis-Plus批量添加或修改數(shù)據(jù)的3種方式,需要的朋友可以參考下2023-05-05SpringBoot整合Quartz實現(xiàn)定時任務(wù)詳解
這篇文章主要介紹了Java?任務(wù)調(diào)度框架?Quartz,Quartz是OpenSymphony開源組織在Job?scheduling領(lǐng)域又一個開源項目,完全由Java開發(fā),可以用來執(zhí)行定時任務(wù),類似于java.util.Timer。,下面我們來學(xué)習(xí)一下關(guān)于?Quartz更多的詳細(xì)內(nèi)容,需要的朋友可以參考一下2022-08-08JSP 開發(fā)之 releaseSession的實例詳解
這篇文章主要介紹了JSP 開發(fā)之 releaseSession的實例詳解的相關(guān)資料,需要的朋友可以參考下2017-07-07Java web項目中的強(qiáng)制登錄功能實現(xiàn)代碼
本文給大家分享Java web項目中的強(qiáng)制登錄功能實現(xiàn)代碼,為了避免直接進(jìn)入項目中存在的頁面,使用filter過濾器,代碼簡單易懂,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2021-11-11springboot中請求地址轉(zhuǎn)發(fā)的兩種方案
在開發(fā)過程中,我們經(jīng)常需要將請求從一個服務(wù)轉(zhuǎn)發(fā)到另一個服務(wù),以實現(xiàn)不同服務(wù)之間的協(xié)作,本文主要介紹了springboot中請求地址轉(zhuǎn)發(fā)的兩種方案,感興趣的可以了解一下2023-11-11Mybatis Order by動態(tài)參數(shù)防注入方式
這篇文章主要介紹了Mybatis Order by動態(tài)參數(shù)防注入方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-04-04