Maven出现 Could not find artifact 的解决方法

在IDEA使用SpringInitializr创建项目时,如果遇到找不到com.mysql:mysql-connector-j依赖的问题,可以检查Maven的settings.xml配置。确保设置了阿里云镜像作为中央仓库的代理,并且只配置了central的镜像。更新settings.xml后,项目构建应能成功避免找不到artifact的错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值