没有版本的Maven依赖 [英] maven dependency without version

查看:689
本文介绍了没有版本的Maven依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我一直在一段时间前开发的项目中进行一些改进,这就是我所发现的. pom文件中的许多依赖项都没有指定版本,但是已经解决了.该项目包含1个根模块和2个子模块.使用了Aggregator模式,这意味着根本没有dependencyManagement部分.上层项目仅聚合了2个模块,仅此而已.子项目并不将其称为父项.他们有不同的父母.我无法理解的是,子项目本身或它们的父项(事实上,它也没有dependencyManagement)都没有为某些依赖项指定版本.例如:

Recently I've been working on some improvements in a project developed some time ago, and here's what I found. A lot of dependencies in the pom files go without versions specified, and yet they are resolved. The project consists of 1 root module and 2 submodules. The Aggregator pattern is used, meaning there's no dependencyManagement section at all. The upper-project simply aggregates 2 modules and that's all it does. Subprojects don't refer to it as to a parent. They have a different parent. What I can't grasp is that neither subprojects themselves nor their parent(as a matter of fact, it doesn't have dependencyManagement either) specify versions for some of the dependencies. For instance:

<dependency>
    <groupId>javax.mail</groupId>
    <artifactId>javax.mail-api</artifactId>
</dependency>
<dependency>
    <groupId>com.sun.mail</groupId>
    <artifactId>javax.mail</artifactId>
</dependency>
<dependency>
    <groupId>com.sun.mail</groupId>
    <artifactId>imap</artifactId>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jul-to-slf4j</artifactId>
</dependency>
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
</dependency>

有人可以帮我解决这个问题吗? Maven是否使用某种默认策略来处理版本控制?该默认策略是什么?

Can someone help me figure this out? Is maven handling versioning with some default strategy? What is that default strategy?

推荐答案

好的,我想我会自己回答.当然,我研究了dependency:tree,但是我提到的所有依赖项都是树的第一级成员.我没有立即注意到的是,dependencyManagement在父级中不存在,但是在子模块中存在,并且更有趣的是:

Ok, I think I'm gonna answer it myself. Of course I took a look at dependency:tree, but all the dependencies that I mentioned were first-level members of the tree. What I failed to notice right away, is that dependencyManagement is not present in the parent, but it is however present in the submodules, and what is more interesting it contains:

        <dependency>
            <groupId>io.spring.platform</groupId>
            <artifactId>platform-bom</artifactId>
            <version>1.0.2.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

我以前从未使用过Spring IO Platform,所以对我来说这是一个全新的概念.事实证明,该平台包括许多预先配置的依赖项: http://docs.spring.io/platform/docs/current/reference/htmlsingle/#appendix-dependency-versions

I've never used Spring IO Platform before, so this is a totally new concept for me. As it turns out the platform includes quite a few preconfigured dependencies: http://docs.spring.io/platform/docs/current/reference/htmlsingle/#appendix-dependency-versions

这篇关于没有版本的Maven依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆