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

相关文章

maven中的maven-antrun-plugin插件示例详解

《maven中的maven-antrun-plugin插件示例详解》maven-antrun-plugin是Maven生态中一个强大的工具,尤其适合需要复用Ant脚本或实现复杂构建逻辑的场景... 目录1. 核心功能2. 典型使用场景3. 配置示例4. 关键配置项5. 优缺点分析6. 最佳实践7. 常见问题

windows系统上如何进行maven安装和配置方式

《windows系统上如何进行maven安装和配置方式》:本文主要介绍windows系统上如何进行maven安装和配置方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不... 目录1. Maven 简介2. maven的下载与安装2.1 下载 Maven2.2 Maven安装2.

Apache 高级配置实战之从连接保持到日志分析的完整指南

《Apache高级配置实战之从连接保持到日志分析的完整指南》本文带你从连接保持优化开始,一路走到访问控制和日志管理,最后用AWStats来分析网站数据,对Apache配置日志分析相关知识感兴趣的朋友... 目录Apache 高级配置实战:从连接保持到日志分析的完整指南前言 一、Apache 连接保持 - 性

Maven项目中集成数据库文档生成工具的操作步骤

《Maven项目中集成数据库文档生成工具的操作步骤》在Maven项目中,可以通过集成数据库文档生成工具来自动生成数据库文档,本文为大家整理了使用screw-maven-plugin(推荐)的完... 目录1. 添加插件配置到 pom.XML2. 配置数据库信息3. 执行生成命令4. 高级配置选项5. 注意事

Linux中的more 和 less区别对比分析

《Linux中的more和less区别对比分析》在Linux/Unix系统中,more和less都是用于分页查看文本文件的命令,但less是more的增强版,功能更强大,:本文主要介绍Linu... 目录1. 基础功能对比2. 常用操作对比less 的操作3. 实际使用示例4. 为什么推荐 less?5.

spring-gateway filters添加自定义过滤器实现流程分析(可插拔)

《spring-gatewayfilters添加自定义过滤器实现流程分析(可插拔)》:本文主要介绍spring-gatewayfilters添加自定义过滤器实现流程分析(可插拔),本文通过实例图... 目录需求背景需求拆解设计流程及作用域逻辑处理代码逻辑需求背景公司要求,通过公司网络代理访问的请求需要做请

Java集成Onlyoffice的示例代码及场景分析

《Java集成Onlyoffice的示例代码及场景分析》:本文主要介绍Java集成Onlyoffice的示例代码及场景分析,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要... 需求场景:实现文档的在线编辑,团队协作总结:两个接口 + 前端页面 + 配置项接口1:一个接口,将o

Maven项目打包时添加本地Jar包的操作步骤

《Maven项目打包时添加本地Jar包的操作步骤》在Maven项目开发中,我们经常会遇到需要引入本地Jar包的场景,比如使用未发布到中央仓库的第三方库或者处理版本冲突的依赖项,本文将详细介绍如何通过M... 目录一、适用场景说明​二、核心操作命令​1. 命令格式解析​2. 实战案例演示​三、项目配置步骤​1

IDEA下"File is read-only"可能原因分析及"找不到或无法加载主类"的问题

《IDEA下Fileisread-only可能原因分析及找不到或无法加载主类的问题》:本文主要介绍IDEA下Fileisread-only可能原因分析及找不到或无法加载主类的问题,具有很好的参... 目录1.File is read-only”可能原因2.“找不到或无法加载主类”问题的解决总结1.File

使用@Cacheable注解Redis时Redis宕机或其他原因连不上继续调用原方法的解决方案

《使用@Cacheable注解Redis时Redis宕机或其他原因连不上继续调用原方法的解决方案》在SpringBoot应用中,我们经常使用​​@Cacheable​​注解来缓存数据,以提高应用的性能... 目录@Cacheable注解Redis时,Redis宕机或其他原因连不上,继续调用原方法的解决方案1