因为上次断网或网速慢的缘故,一些maven项目的jar包没有下载完整,就可能会在本地maven库里残留相应的.lastUpdated后缀文件,这样导致下次启动该项目时,即使网速好了,也不一定能加载该jar包了,这时就需要清除掉这种上次的残留文件了。最近在网上搜到了一个比较好的脚本工具,清除起来很方便实用。需注意:路径中的文件夹名里面不能包含空格,否则会报“找不到路径”的错误,由于我的maven库建在了Program Files目录下了,就杯具了。
1. [代码]cleanLastUpdated.bat(Windows版本)
@echo off
rem 这里写你的仓库路径
set REPOSITORY_PATH=F:\study\apache-maven-3.0.3\repository
rem 正在搜索...
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
del /s /q %%i
)
rem 搜索完毕
pause
2. [代码]cleanLastUpdated.sh(mac/linux版本)
# 这里写你的仓库路径
REPOSITORY_PATH=~/Documents/tools/apache-maven-3.0.3/repository
echo 正在搜索...
find $REPOSITORY_PATH -name "*lastUpdated*" | xargs rm -fr
echo 搜索完