maven仓库中的LastUpdated文件生成原因及删除

在使用idea离线导入maven仓库的时候总是提示jar文件导入不成功的错误,后经过分析,发现不成功的文件夹里面存在lastUpdate后缀名的文件,删除该文件也未曾生效,依然会重新生成,后经过分析_remote.repositories文件,发现如下的情况

junit-3.8.1.pom>nexus=
junit-3.8.1.jar>nexus=
junit-3.8.1.jar>central=
junit-3.8.1.pom>central=


    maven的setting.xml配置如下

<mirrors>
    <mirror>
        <id>nexus</id>
        <mirrorOf>central</mirrorOf>
        <name>nexus</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
</mirrors>


    通过我测试发现,我设置aliyun仓库的时候,会更新_remote.repositories为如下内容

junit-3.8.1.pom>nexus=
junit-3.8.1.jar>nexus=


    如果我将aliyun仓库注释掉,默认使用外网maven仓库,此时_remote.repositories为如下内容

junit-3.8.1.pom>nexus=
junit-3.8.1.jar>nexus=
junit-3.8.1.jar>central=
junit-3.8.1.pom>central=


    原来每次在更新maven项目的时候,每一个jar包路径下的_remote.repositories文件都会同setting.xml中设置的仓库地址id进行判断,如果没有匹配,会自动更新该jar包的相关文件,如果未联网则会出现jar无法发现的错误,导致即使jar存在,maven项目也无法使用该jar的情况。如果使用公司的内网仓库,_remote.repositories文件变为_maven.repositories。

    最后,附上删除lastupdated脚本文件

    1、cleanLastUpdated.bat(windows版本)

@echo off
rem create by NettQun
  
rem 这里写你的仓库路径
set REPOSITORY_PATH=D:\Java\maven-repository\maven-aliyun\repository
rem 正在搜索...
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
    echo %%i
    del /s /q "%%i"
)
rem 搜索完毕
pause


    2、cleanLastUpdated.sh(linux版本)

# create by NettQun
 
# 这里写你的仓库路径
REPOSITORY_PATH=~/Documents/tools/repository
echo 正在搜索...
find $REPOSITORY_PATH -name "*lastUpdated*" | xargs rm -fr
echo 搜索完

--------------------- 
作者:紫雪群飘 
来源:CSDN 
原文:https://blog.csdn.net/u011990675/article/details/80066897 
版权声明:本文为博主原创文章,转载请附上博文链接!

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值