Maven使用時的錯誤

Maven使用時的錯誤

maven使用時出現了不少錯誤,記錄一下。apache

1、下載錯誤

基本插件下載異常

Could not calculate build plan: 
Plugin org.apache.maven.plugins:maven-jar-plugin:2.4 or one of its dependencies could not be resolved:
Failure to transfer org.apache.maven.plugins:maven-jar-plugin:jar:2.4 from
http://maven.aliyun.com/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of alimaven has elapsed or updates are forced. Original error....

上面這類錯誤是由於本地庫下載的相關文件出錯了(因此只能從新下載)。
解決辦法eclipse

  • 方法一。在本地庫中刪掉相應的文件,而後從新下載。遇到maven-jar-plugin有問題,就把本地庫中plugin所有刪掉,從新下載。
    IDE自動下載不行的話,用mvn命令(package)來自動下載。
  • 方法二(能夠解決不少其餘問題)。eclipse項目右鍵->Maven->update project...->(選中Force Update of Shapshots/Release)點ok

依賴下載錯誤

在pom.xml中添加依賴時,添加失敗,找不到相應的jar。
解決方法:把本地庫相應文件刪掉,從新在pom.xml中添加依賴(一次不行就試多幾回)。maven

2、配置錯誤

在maven安裝目錄下,修改setting文件的jdk默認版本配置信息(在profiles中添加),可是沒有效果.
解決方法:放在profile標籤裏面,修改爲功。ui

<!-- 沒有添加profile標籤,配置失效 -->
    <profile>
        <!-- 修改默認jdk版本 -->
    	<id>jdk-1.8</id>    
     	<activation>    
        	<activeByDefault>true</activeByDefault>    
        	<jdk>1.8</jdk>    
      	</activation>    
	    <properties>    
	        <maven.compiler.source>1.8</maven.compiler.source>    
	        <maven.compiler.target>1.8</maven.compiler.target>
	        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> 
	    </properties>
    </profile>
相關文章
相關標籤/搜索