MAVEN仓库中LastUpdated文件生成原因及删除方法[Windows和Linux]

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

MAVEN依赖中由于各种原因(网速慢、断网)导致jar包下载不下来,出现很多.lastUpdated文件。同时一个Jar包中可能依赖其余Jar包。如果一个一个删除太麻烦。所以需要一个批量操作的脚本。

在这里插入图片描述下载完毕之后的结果

在这里插入图片描述

hbase-client-2.2.1.pom.lastUpdated 内容如下:

#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Mon Dec 30 21:11:22 CST 2019
@default-central-https\://repo.maven.apache.org/maven2/.lastUpdated=1577711482223
https\://repo.maven.apache.org/maven2/.error=Could not transfer artifact org.apache.hbase\:hbase-client\:pom\:2.2.1 from/to central (https\://repo.maven.apache.org/maven2)\: Connect to repo.maven.apache.org\:443 [repo.maven.apache.org/151.101.24.215] failed\: Connection timed out\: connect

maven仓库中的LastUpdated文件删除方法

Windows脚本如下: 脚本名字为:cleanLastUpdated.bat 【双击可运行】

【C:\Users\yuhui.m2\repository】这个路径要改成你自己的maven路径

set REPOSITORY_PATH=C:\Users\yuhui\.m2\repository
rem 正在搜索...
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
    del /s /q %%i
)
rem 搜索完毕
pause

Mac或者Linux脚本如下:

find ~/.m2/repository -type f -name "*.lastUpdated" -exec rm -f {} \;


说明:
•old:待查找的开始目录,搜索其下的子目录
•-type f : 文件类型为普通文件   若查找的目标文件是目录,则用 -type d
•-name "*.l" :  表示文件名与"*.l"匹配,双引号不能少!
•rm -f {} : 删除时,不提示,{}表示查找到的文件
ps :  {} 和\之间需要加空格
发布了422 篇原创文章 · 获赞 357 · 访问量 124万+

猜你喜欢

转载自blog.csdn.net/silentwolfyh/article/details/103773701
今日推荐