- 检查标红的依赖jar包在仓库中是否成功下载。首先打开settings

- 找到Maven,打开红框内的文件地址

- 在该文件中找到要导入的包,打开

- 如下图所示的dom4j,若包含如下多个文件,则下载成功,否则,下载失败。

- 失败例子如下。将4.13文件夹删除,然后在代码页面右键,选Maven,Reimport


- 再次重复上述步骤,检查是否下载成功。若仍失败,则可能有些版本设置的仓库 下载不下来,此时需要更换成国内的仓库。打开红框内地址文件settings.xml

- 更改为如下设置,保存即可。
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
<!-- 中央仓库1 -->
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<!-- 中央仓库2 -->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
</mirrors>
</settings>
- 再次查看pom.xml中导入的依赖,已经没有红色了。