Maven使用时的错误

Maven使用时的错误

maven使用时出现了很多错误,记录一下。

一、下载错误

基本插件下载异常

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....

上面这类错误是因为本地库下载的相关文件出错了(所以只能重新下载)。
解决办法

  • 方法一。在本地库中删掉相应的文件,然后重新下载。遇到maven-jar-plugin有问题,就把本地库中plugin全部删掉,重新下载。
    IDE自动下载不行的话,用mvn命令(package)来自动下载。
  • 方法二(可以解决很多其他问题)。eclipse项目右键->Maven->update project...->(选中Force Update of Shapshots/Release)点ok

依赖下载错误

在pom.xml中添加依赖时,添加失败,找不到相应的jar。
解决方法:把本地库相应文件删掉,重新在pom.xml中添加依赖(一次不行就试多几次)。

二、配置错误

在maven安装目录下,修改setting文件的jdk默认版本配置信息(在profiles中添加),但是没有效果.
解决方法:放在profile标签里面,修改成功。

    <!-- 没有添加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>

猜你喜欢

转载自www.cnblogs.com/tddc10/p/12670463.html