maven报错

在IntelliJ IDEA中构建maven项目的时,出现了报错:ArchetypeDataSourceException

一,报错具体信息:

[WARNING] failed to download from remote org.apache.maven.archetype.source.ArchetypeDataSourceException: org.eclipse.aether.transfer.MetadataNotFoundException: Could not find metadata /archetype-catalog.xml in aliyunmaven (https://maven.aliyun.com/repository/public)

二,报错分析

报错:“failed to download from remote org.apache.maven.archetype.source.ArchetypeDataSourceException” 的原因是因为随机书写了一个archetype,如图所示,在IntelliJ IDEA2024中这样书写archetype进行创建是不正确的。

在这里插入图片描述

可按照自己定义的坐标设置应该在红框位置进行设定

在这里插入图片描述

archetype不是提供给开发人员进行随意书写的地方,Maven 在创建项目时,会尝试从远程仓库中下载指定的 archetype,如果这个 archetype 不存在或者填写不正确,就会出现 “failed to download from remote” 这样的错误。

常用的 Maven Archetype

  1. maven-archetype-quickstart:最基础的 Maven 项目模板,包含一个简单的 Java 项目结构(src/main/java 和 src/test/java)。
    • Group Id: org.apache.maven.archetypes
    • Artifact Id: maven-archetype-quickstart
  2. maven-archetype-webapp:适用于创建 Web 应用程序的基础结构,包含 src/main/webappWEB-INF 目录。
    • Group Id: org.apache.maven.archetypes
    • Artifact Id: maven-archetype-webapp
  3. maven-archetype-archetype:一个通用的项目模板,用于创建你自己的 Maven archetype(项目模板)。
    • Group Id: org.apache.maven.archetypes
    • Artifact Id: maven-archetype-archetype
  4. spring-boot-sample-data-jpa(适用于 Spring Boot 项目):创建包含 Spring Boot 和 JPA 配置的项目结构。
    • Group Id: org.springframework.boot
    • Artifact Id: spring-boot-sample-data-jpa

三,解决方案

设定正确的Maven Archetype,在Advanced Settings处设定Maven项目的坐标信息

在这里插入图片描述

如果设定了正确的 ,出现了警告,警告内容为:

[WARNING] failed to download from remote
org.apache.maven.archetype.source.ArchetypeDataSourceException: org.eclipse.aether.transfer.MetadataNotFoundException: /archetype-catalog.xml was not found in https://maven.aliyun.com/repository/public during a previous attempt. This failure was cached in the local repository and resolution is not be reattempted until the update interval of aliyunmaven has elapsed or updates are forced

of aliyunmaven has elapsed or updates are forced

其实主要的警告是 Maven 无法从阿里云镜像下载 archetype-catalog.xml 文件,导致 Archetype 的选择出现问题。由于项目已经成功创建,且只是一些仓库访问的警告信息,这些警告并不影响项目的实际构建。可以选择忽略这些警告,继续使用项目。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值