使用maven 容易遇到的问题

项目中使用了maven,而且搭建了nexus 私服。

经常会遇到如下问题:

(一)

使用maven构建的项目下面都有一个pom.xml文件,里面设置了该项目的依赖的jar包。第一次因为没有联网或者nexus服务未启动,导致下载jar失败,以后依然下载失败。后来终于找到了原因:

因为第一次下载失败时,会在C:\Users\huangwei\.m2\repository 中生成对应jar包的lastUpdated文件,如xwork-core-2.1.6.jar.lastUpdated。因为有这个lastUpdated文件,所以以后都不会真正下载xwork-core-2.1.6.jar了。

解决方法:(1)在执行mvn compile 之前把lastUpdated 文件删除;

 

(2)mvn compile -U

 

(二)使用maven 编译(mvn compile)时,报错:maven source 1.3 中不支持泛型

解决方法:在项目的pom.xml中添加:


    
      
        org.apache.maven.plugins
        maven-compiler-plugin
        
          1.6
          1.6
        
      
    
	

 

 

 

(三)执行 mvn deploy时报错:java.lang.OutOfMemoryError: Java heap space



 

解决方法:

执行deploy时指定jre的参数

-Xms128M -Xmx512M

 

 

(四)使用nexus 时,eclipse中 Maven Repositories 视图中的Global Repositories下的nexus 无法展开



 解决方法:

对nexus 中Public Repositories 先执行“Rebuild Metadata”,再执行“Update Index”:



 

(五)使用eclipse 执行deploy部署项目时报错,报错信息如下:

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]

 项目名为demoManagement

刚开始以为是pom。xml中finalName 引起的。结果发现nexus 压根儿没有叫“kunlun_management_release”的仓库。

根本原因:pom.xml中snapshotRepository指定的仓库不存在

你可能感兴趣的:(java,web,maven,nexus,私服,jar包失败,lastUpdated)