maven自动下载jar包失效解决办法

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

经常会遇到如下问题:

(一)

众所周知,Maven在下载仓库中找不到相应资源时,会生成一个.lastUpdated为后缀的文件。如果这个文件存在,那么即使换一个有资源的仓库后,Maven依然不会去下载新资源。

解决方法:

 (1)在执行mvn compile 之前把lastUpdated 文件删除;

 (2)mvn compile -U

 (3)

除了网上所说的在参数中加入-U以外,本文还提供另外一种方法,可以使大家不用删除.lastUpdated文件的情况下,让Maven去查找最新资源。

正常情况下,我们是把仓库地址配置在settings.xml文件中的mirror节点下,这时如果生成了.lastUpdated文件,默认Maven是不会去取最新资源,但是如果我们把仓库资源配置在settings.xml的<profile>节点中,而不是mirror节点,那么即使更新失败,下一次同步也会忽略这些文件(注意:本人对Maven研究还很浅薄,不清楚使用profile配置仓库和使用mirror到底有什么区别和影响,这里仅仅列出此方法,在没有把握的情况下不推荐大家使用)。

<profile>配置如下:

<profiles>
  <profile>
    <id>dev<id>	<!-- 这个id要和activeProfile里的id一样 -->
    <repositories>
      <repository>
        <id>Nexus</id>
        <url>http://192.168.9.91:8084/nexus/content/groups/futuresoftware</url>
        <releases>
         <enabled>true</enabled>
        </releases>
        <snapshots>
         <enabled>true</enabled>
        </snapshots>
      </repository>
    </repositories>
  </profile>
</profiles>
<activeProfiles> 
  <activeProfile>dev</activeProfile>
</activeProfiles>


 

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

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

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>  
(三)执行 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部署项目时报错,报错信息如下:

Xml代码 
    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指定的仓库不存在


 
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值