本文主要解决settings.xml文件配置的不对导致的下载依赖不成功只能下载lastUpdate文件问题。
setting.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!--本地仓库。该值表示构建系统本地仓库的路径。其默认值为${user.home}/.m2/repository。 -->
<localRepository>C:\Users\LENOVO\.m2\repository</localRepository>
<!--Maven是否需要和用户交互以获得输入。如果Maven需要和用户交互以获得输入,则设置成true,反之则应为false。默认为true。 -->
<interactiveMode>true</interactiveMode>
<!--Maven是否需要使用plugin-registry.xml文件来管理插件版本。 -->
<!--如果设置为true,则在{user.home}/.m2下需要有一个plugin-registry.xml来对plugin的版本进行管理 -->
<!--默认为false。 -->
<usePluginRegistry>false</usePluginRegistry>
<!--表示Maven是否需要在离线模式下运行。如果构建系统需要在离线模式下运行,则为true,默认为false。 -->
<!--当由于网络设置原因或者安全因素,构建服务器不能连接远程仓库的时候,该配置就十分有用。 -->
<offline>false</offline>
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
<mirrors>
<!-- 阿里代理镜像地址 -->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
</settings>
重新下载依赖前要讲仓库中对应的.lastUpdated文件删除。
运行下面的批处理文件可以批量删除仓库中的.lastUpdated文件
clearLastUpdated.bat
@echo off
rem create by NettQun
rem 这里写你的仓库路径
set REPOSITORY_PATH=C:\Users\LENOVO\.m2\repository
rem 正在搜索...
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
echo %%i
del /s /q "%%i"
)
rem 搜索完毕
pause
删除后重新下载依赖就可以了