1. 问题描述
在IDEA创建Spring Initializr项目,选择下载依赖时,项目构建时爆出:Could not find artifact com.mysql:mysql-connector-j:pom:unknown in central (https://repo.maven.apache.org/maven2)
2. 解决办法
(1)假如settings.xml 指定阿里云源
mirror仅仅配置central的代理镜像,其它仓库通过settings文件的profile或pom文件来配置
可以通过IDEA中maven的配置找到该文件位置(构建工具 ——Maven——用户设置文件)
settings.xml文件配置内容
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>aliyun-maven-mirror</id>
<mirrorOf>centeral</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
<profiles>
</profiles>
</settings>
然后重新构建,就不会报Could not find artifact