天天看点

如何替换Maven下载依赖时使用的仓库地址

最近因为疫情的原因在家办公,使用maven自动下载依赖时,使用的nexus仓库是国外的,在家下载依赖速度很慢。

如何替换Maven下载依赖时使用的仓库地址
mvn -v查询到Maven本地安装目录,进入该目录,打开conf文件夹下面的settings.xml文件:
如何替换Maven下载依赖时使用的仓库地址
在mirrors标签页里,添加一个新的mirror标签,
如何替换Maven下载依赖时使用的仓库地址
将阿里云的Maven仓库地址明细维护进settings.xml:

<mirror>

<id>alimaven</id>

<mirrorOf>central</mirrorOf>

<name>aliyun maven</name>

<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>

</mirror>

<mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>      
如何替换Maven下载依赖时使用的仓库地址

build成功:

如何替换Maven下载依赖时使用的仓库地址