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>
相关文章
相关标签/搜索