腳本地址: github.com/jayknoxqu/c…git
使用maven下載項目依賴的jar包時,很容易由於各類緣由(網速慢、斷網)致使jar包下載失敗,出現不少xxx.jar.lastUpdated的文件,沒法正常啓動項目,須要及時清理。github
執行cleanLastUpdated.bat ~/.m2/repository
,其中"~/.m2/repository"目錄爲Maven本地倉庫路徑bash
@echo off
set REPOSITORY_PATH=%1
if "%REPOSITORY_PATH%" == "" (
echo "Usage: %0 <maven_repository_path>"
echo "Example: %0 ~/.m2/repository"
echo "Explain: "~" is your profile's home directory"
echo.
echo.
echo "press enter to quit!" & pause > nul
goto :eof
)
echo.
echo "Began clean lastUpdated file"
echo.
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
del /s /q %%i
)
echo.
echo "End clean lastUpdated file."
echo.
echo.
echo "press enter to exit!" & pause > nul
exit
複製代碼
執行./cleanLastUpdated.sh ~/.m2/repository
,其中"~/.m2/repository"目錄爲Maven本地倉庫路徑maven
#!/bin/bash
REPOSITORY_PATH=$1
if [ "$REPOSITORY_PATH" = "" ]; then
echo "Usage: $0 <maven_repository_path>"
echo "Example: $0 ~/.m2/repository"
echo "Explain: "~" is your profile's home directory"
exit 1
fi
echo "Began clean lastUpdated file"
for f in `find $REPOSITORY_PATH -name "*lastUpdated*"`
do
echo $f & rm $f
done
echo "End clean lastUpdated file."
複製代碼