脚本地址: 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."
复制代码