maven依赖下载失败原因分析;_remote.repositories简述

2023-10-11 08:12

本文主要是介绍maven依赖下载失败原因分析;_remote.repositories简述,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

概述

我的maven版本3.6.3

有时在下载maven依赖时,提示某个仓库中没有对应依赖,此时去提示的仓库上找,的确没有,那么通常会加入mirror拦截一下依赖请求,指向到mirrot中的仓库,但是此时仍提示相同的错误。
更奇怪的是,即使此时本地仓库中有依赖,但还是提示某个仓库地址上依赖不存在。

查了一通,资料,到对应依赖下把_remote.repositories文件删除,重新下载依赖就ok了。

附上一个相同问题的Stack Overflow连接
https://stackoverflow.com/questions/16866978/maven-cant-find-my-local-artifacts

_remote.repositories

大致就是说_remote.repositories这个文件是为了标识依赖的来源,需要保证这个来源中依赖一定存在。

这个文件内容大概如下,>符号后的字符为setting文件中配置的<mirror>标签下的id.
如下demo中我用是mirroraliyun的这里展示的就是aliyun
在这里插入图片描述

官方解释

Prior to Maven 3.0.x, Maven did not track the origin of files in the
local repository.

This could result in build issues, especially if you were building
something that listed the (now dead) very borked java.net2
repository… Not only did that repository change released artifacts
(extremely bad and evil practice) but it also published artifacts at
the same coordinates as artifacts on central but with different
content (unbelievably evil)

So you could have the build work (because you had
commons-io:commons-io:2.0 from central) wipe your local repo and the
build fails (because you now get commons-io:commons-io:2.0 from
java.net2 which was a completely different artifact with different
dependencies in the pom) or vice versa.

The above situation is one of the drivers for using a maven repository
manager, because that allows you to control the subset of a repository
that you expose downstream and the order in which artifacts are
resolved from multiple repositories (usually referred to as routing
rules)

In any case, when maven switched to Aether as the repository access
layer, the decision was made to start tracking where artifacts come
from.

So with Maven 3.0.x, when an artifact is downloaded from a repository,
maven leaves a _maven.repositories file to record where the file was
resolved from. If you are building a project and the effective list of
repositories does not include the location that the artifact was
resolved from, then Maven decides that it is as if the artifact was
not in the cache, and will seek to re-resolve the artifact…

There are a number of bugs in 3.0.x though… The most critical being
how offline is handled… Namely: when offline, maven 3.0.x thinks
there are no repositories, so will always find a mismatch against the
_maven.repositories file!!!

The workaround for Maven 3.0.x is to delete these files from your
local cache, eg

$ find ~/.m2/repository -name _maven.repositories -exec rm -v {} ;
The side effect is that you loose the protections that Maven 3.0.x is
trying to provide.

The good news is that Maven 3.1 will have the required fix (if we can
ever get our act together and get a release out the door)

With Maven 3.1 when in offline mode the _maven.repositories file is
(semi-)ignored, and there is also an option to ignore that file for
online builds (referred to as legacy mode)

At this point in time (June 1st 2013) the 4th attempt to cut a release
that meets the legal and testing requirements is in progress… So,
assuming that the 4th time is lucky, I would hope to see 3.1.0-alpha-1
released in 3-4 days time… But it could be longer given that we want
to give the changes in 3.1 enough time to soak to ensure uses builds
don’t break (there was a change in an API exposed (by accident-ish -
the API is needed by the site and dependency plugin) that plugin
authors have depended on (even though they shouldn’t have) so there is
potential, though we think we have all the bases covered)

这篇关于maven依赖下载失败原因分析;_remote.repositories简述的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/186732

相关文章

IDEA编译报错“java: 常量字符串过长”的原因及解决方法

《IDEA编译报错“java:常量字符串过长”的原因及解决方法》今天在开发过程中,由于尝试将一个文件的Base64字符串设置为常量,结果导致IDEA编译的时候出现了如下报错java:常量字符串过长,... 目录一、问题描述二、问题原因2.1 理论角度2.2 源码角度三、解决方案解决方案①:StringBui

部署Vue项目到服务器后404错误的原因及解决方案

《部署Vue项目到服务器后404错误的原因及解决方案》文章介绍了Vue项目部署步骤以及404错误的解决方案,部署步骤包括构建项目、上传文件、配置Web服务器、重启Nginx和访问域名,404错误通常是... 目录一、vue项目部署步骤二、404错误原因及解决方案错误场景原因分析解决方案一、Vue项目部署步骤

Springboot中分析SQL性能的两种方式详解

《Springboot中分析SQL性能的两种方式详解》文章介绍了SQL性能分析的两种方式:MyBatis-Plus性能分析插件和p6spy框架,MyBatis-Plus插件配置简单,适用于开发和测试环... 目录SQL性能分析的两种方式:功能介绍实现方式:实现步骤:SQL性能分析的两种方式:功能介绍记录

pip install jupyterlab失败的原因问题及探索

《pipinstalljupyterlab失败的原因问题及探索》在学习Yolo模型时,尝试安装JupyterLab但遇到错误,错误提示缺少Rust和Cargo编译环境,因为pywinpty包需要它... 目录背景问题解决方案总结背景最近在学习Yolo模型,然后其中要下载jupyter(有点LSVmu像一个

最长公共子序列问题的深度分析与Java实现方式

《最长公共子序列问题的深度分析与Java实现方式》本文详细介绍了最长公共子序列(LCS)问题,包括其概念、暴力解法、动态规划解法,并提供了Java代码实现,暴力解法虽然简单,但在大数据处理中效率较低,... 目录最长公共子序列问题概述问题理解与示例分析暴力解法思路与示例代码动态规划解法DP 表的构建与意义动

Spring AI Alibaba接入大模型时的依赖问题小结

《SpringAIAlibaba接入大模型时的依赖问题小结》文章介绍了如何在pom.xml文件中配置SpringAIAlibaba依赖,并提供了一个示例pom.xml文件,同时,建议将Maven仓... 目录(一)pom.XML文件:(二)application.yml配置文件(一)pom.xml文件:首

Java下载文件中文文件名乱码的解决方案(文件名包含很多%)

《Java下载文件中文文件名乱码的解决方案(文件名包含很多%)》Java下载文件时,文件名中文乱码问题通常是由于编码不正确导致的,使用`URLEncoder.encode(filepath,UTF-8... 目录Java下载文件中文文件名乱码问题一般情况下,大家都是这样为了解决这个问题最终解决总结Java下

CentOS系统Maven安装教程分享

《CentOS系统Maven安装教程分享》本文介绍了如何在CentOS系统中安装Maven,并提供了一个简单的实际应用案例,安装Maven需要先安装Java和设置环境变量,Maven可以自动管理项目的... 目录准备工作下载并安装Maven常见问题及解决方法实际应用案例总结Maven是一个流行的项目管理工具

SpringBoot中的404错误:原因、影响及解决策略

《SpringBoot中的404错误:原因、影响及解决策略》本文详细介绍了SpringBoot中404错误的出现原因、影响以及处理策略,404错误常见于URL路径错误、控制器配置问题、静态资源配置错误... 目录Spring Boot中的404错误:原因、影响及处理策略404错误的出现原因1. URL路径错

使用maven依赖详解

《使用maven依赖详解》本文主要介绍了Maven的基础知识,包括Maven的简介、仓库类型、常用命令、场景举例、指令总结、依赖范围、settings.xml说明等,同时,还详细讲解了Maven依赖的... 目录1. maven基础1.1 简介1.2 仓库类型1.3 常用命令1.4 场景举例1.5 指令总结