因某项目需要在内网开发,不可连接互联网下载相关依赖。通过外网下载好的maven本地仓库拷贝到内网使用。

配置maven settings.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?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">

<localRepository>D:/mavenRepository</localRepository>

<mirrors>
<mirror>
<id>central</id>
<name>central</name>
<!-- 将镜像地址设置为本地maven地址 -->
<url>file://D:/mavenRepository</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
</settings>

配置idea,开启离线模式

idea Reload peoject

maven离线打包时出现Cannot access central xxxxx in offline mode

删除 D:/mavenRepository 目录下所有的 _remote.repositories 文件