本文介绍了Maven版本范围-下载所有可用版本,而不仅仅是最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个模块:A和B.A取决于B.

I have two modules: A and B.A depends from B.

在模块A中,对B的依赖项具有以下版本设置:[1.0.0,)

In the module A there is a dependency to B with the following version setting: [1.0.0,)

在B中有两个版本:1.0.0-1和1.0.0-2. 1.0.0-1已过时,它缺少一些依赖关系,因此我无法从中创建一个版本.但是1.0.0-2可以正常工作.

From the B there are two versions: 1.0.0-1 and 1.0.0-2. The 1.0.0-1 is out of date, it has some missing dependencies, hence I cannot create a build from it. But the 1.0.0-2 is working fine.

当我为模块A使用安装程序时,我得到一个错误,即B:1.0.0-1缺少依赖项.

When I use the install for the module A I get an error that B:1.0.0-1 has a missing dependency.

之所以这样,是因为行家从1.0.0下载了所有版本,而不仅仅是最后一个.

That's happening because the maven downloaded all the versions from the 1.0.0 not just the last one.

如果我使用LATEST,那么仅会下载1.0.0-2,但这不是我想要的.基本上,我只想从1.0.0下载最新版本.

If I would use LATEST then just the 1.0.0-2 would be downloaded, but it's not what I want. Basically I would like to download just the latest from the 1.0.0.

我该怎么做?

谢谢您的回答!

(Maven版本:3.5.0)

(Maven version: 3.5.0)

推荐答案

首先不要使用版本范围,因为它们会使您的构建不可复制.更新依赖关系.除此之外,1.0.0-11.0.0-2之间有什么区别..根据您的解释,我认为您应该更改版本架构,因为第二个版本与第一个版本不兼容,所以我会说2.0.0而不是1.0.0-2 .. or被视为错误修复程序,比1.0.1 ...(随后是semver).另一点LATEST被标记为已弃用很长时间了,它将在以后的Maven版本中产生警告.

First don't use versions ranges cause they make your build non reproducible.. If you like to update things like that you can use versions-maven-plugin to update the dependency. Apart from that what is the difference between 1.0.0-1 and 1.0.0-2..From your explanations i would assume you should change your versions schema cause the second one is not compatible with the first one so I would say 2.0.0 instead of 1.0.0-2..or is see it as a bug fix than 1.0.1...(following semver). Another point LATEST is marked deprecated for a long time and will produce a WARNING in the next Maven versions..

向您解释:我怀疑所有工件都已下载...如果您查看日志记录输出,我认为有些行说...maven-metadata.xml将被下载...

Coming to you explanations: I have my doubts that all artifacts are being downloaded...If you take a look at the logging output I assume there are some line saying ...maven-metadata.xml will be downloaded...

答案的第一部分...

First part of the answer...

这篇关于Maven版本范围-下载所有可用版本,而不仅仅是最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 15:20