建立 maven web project時遇到的問題

來源:互聯網
上載者:User

標籤:users   pos   技術   xstream   clip   ash   art   groups   9.png   

突然想學maven,沒想到建項目的過程,就經曆的各種坑。。。

一開始建的是maven project,並且勾選了simple project,

很順利沒有任何問題,項目結構是這樣

 

看起來過於簡單,於是一番查詢後,開始進一步嘗試,選擇quickstart模板

 報錯: Missing artifact junit:junit:jar:4.5

解決:Window——priferences——Myeclipse——Maven,將offline設定為不選,隨便在pom.xml按一下空格然後儲存,它就可以自動下載jar檔案了。。

 

接下來又嘗試了一下webapp模板,這回出現了很多問題

首先在右下角一直在載入Retrieving archetypes,導致特別卡,最後報錯,An internal error occurred during: "Retrieving archetypes:". GC overhead limit exceeded,大概的意思就是記憶體溢出,看了下工作管理員在載入的時候竟然達到一千多兆,查資料都很散,糾結了一整天。。

一種是修改myeclipse.ini檔案,我的修改如下:

-Xms:JVM初始分配的記憶體 預設是實體記憶體的1/64

-Xmx:JVM最大分配的記憶體 預設是實體記憶體的1/4

-XX:最大非堆記憶體的大小,預設是實體記憶體的1/4

看到有高手總結最佳化MyEclipse速度的主要方法:

1.修改myeclipse.ini。
2.取消自動validation
3.勾掉無用外掛程式。
4.修改啟動載入模組

但是上面這種方法沒有改變我的問題

後來嘗試了一下不用myeclipse內建的外掛程式

解決:Window——priferences——Myeclipse——Maven——Archetypes

 

選擇Add Remote catalog,catalog file填寫:http://repo1.maven.org/maven2/archetype-catalog.xml

或者將archetype-catalog.xml 下載到本地,選擇Add Local catalog,填寫路徑,比連網要快。。。然後點擊Apply->OK。

然後選擇我們建立的作為Catalog

剛剛接觸maven很多東西都是知其然不知其所以然,但是有一點是conf目錄下的setting.xml檔案非常重要,裡面設定了中央庫的位置,預設是在C:\Users\xxx\.m2\repository下,但是可以根據自己的需要修改,並且在window-preferences-MyEclipse-Maven4MyEclipse-User Setting裡面的Local Repository與設定檔的位置保持一致

除此之外還有代理,鏡像,在下載jar檔案時往往比較慢,是因為訪問國外的網站,可以在鏡像中做如下修改

<mirror>

<id>CN</id>
<name>OSChina Central</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<mirrorOf>central</mirrorOf>

</mirror>

方法有一堆,但在我這並沒有起到太大的作用,換了工作空間也是如此,條條大路通羅馬,這次直接建web project,並選擇 Add maven

報了這樣一個錯,

Description Resource Path Location Type
Failure to transfer com.thoughtworks.xstream:xstream:pom:1.3.1 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact com.thoughtworks.xstream:xstream:pom:1.3.1 from/to central (http://repo.maven.apache.org/maven2): The operation was cancelled.pom.xml/Testline 1Maven Configuration Problem

直到現在也沒有解決,但意外的是,這個錯誤並沒有影響運行(希望有人可以告訴我這是怎麼回事,一個紅叉叉,逼死強迫症啊)

 

 測試一下,在pom.xml檔案中加入如下代碼,

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>

右下角可以看到正在下載對應的jar到我們的庫裡

—————————————————————————————

—————————————————————————————

作為沒有經驗的新手,身邊沒有可以幫忙答疑的大神,只能一步一個坑的走了。。。

接下來要研究一下maven與一些主流架構的整合。。。

坑坑坑。。。

 

建立 maven web project時遇到的問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.