国内访问repo1.maven.org访问不了,导致maven不能下载依赖,解决方法是自己设置maven的mirrors,就是设置镜像:
在~/.m2/目录下建立一个settings.xml文件,内容如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<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 | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | --> <mirror> <id>id</id> <mirrorOf>central</mirrorOf> <name>name</name> <url>http://XXX</url> </mirror> </mirrors> </settings> |
最好是公司或者自己设置的镜像地址,公网地址基本上不怎么靠谱,不是修改了包的内容打广告就是稳定性很差。
注意,如果由于更换代理导致问题,可以尝试删除~/.m2/repository 目录。