項目中使用了maven,而且搭建了nexus 私服。
經(jīng)常會(huì )遇到如下問(wèn)題:
(一)
使用maven構建的項目下面都有一個(gè)pom.xml文件,里面設置了該項目的依賴(lài)的jar包。第一次因為沒(méi)有聯(lián)網(wǎng)或者nexus服務(wù)未啟動(dòng),導致下載jar失敗,以后依然下載失敗。后來(lái)終于找到了原因:
因為第一次下載失敗時(shí),會(huì )在C:\Users\huangwei\.m2\repository 中生成對應jar包的lastUpdated文件,如xwork-core-2.1.6.jar.lastUpdated。因為有這個(gè)lastUpdated文件,所以以后都不會(huì )真正下載xwork-core-2.1.6.jar了。
解決方法:(1)在執行mvn compile 之前把lastUpdated 文件刪除;
0?2
(2)mvn compile -U
0?2
(二)使用maven 編譯(mvn compile)時(shí),報錯:maven source 1.3 中不支持泛型
解決方法:在項目的pom.xml中添加:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build>
0?2
0?2
0?2
(三)執行 mvn deploy時(shí)報錯:java.lang.OutOfMemoryError: Java heap space

解決方法:
執行deploy時(shí)指定jre的參數
-Xms128M -Xmx512M

(四)使用nexus 時(shí),eclipse中 Maven Repositories 視圖中的Global?0?2Repositories下的nexus 無(wú)法展開(kāi)

對nexus 中Public?0?2Repositories 先執行“Rebuild Metadata”,再執行“Update Index”:

0?2
(五)使用eclipse 執行deploy部署項目時(shí)報錯,報錯信息如下:
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project demoManagement: Failed to deploy artifacts: Could not find artifact com.kunlunsoft.jn:demoManagement:war:1.1.0-RELEASE in tdr_vks_management_release (http://192.168.2.150:8088/nexus/content/repositories/kunlun_management_release/) -> [Help 1]
0?2項目名為demoManagement
剛開(kāi)始以為是pom。xml中finalName 引起的。結果發(fā)現nexus 壓根兒沒(méi)有叫“kunlun_management_release”的倉庫。
根本原因:pom.xml中snapshotRepository指定的倉庫不存在。
聯(lián)系客服