• <tfoot id='l5Ux2'></tfoot>

    <i id='l5Ux2'><tr id='l5Ux2'><dt id='l5Ux2'><q id='l5Ux2'><span id='l5Ux2'><b id='l5Ux2'><form id='l5Ux2'><ins id='l5Ux2'></ins><ul id='l5Ux2'></ul><sub id='l5Ux2'></sub></form><legend id='l5Ux2'></legend><bdo id='l5Ux2'><pre id='l5Ux2'><center id='l5Ux2'></center></pre></bdo></b><th id='l5Ux2'></th></span></q></dt></tr></i><div id='l5Ux2'><tfoot id='l5Ux2'></tfoot><dl id='l5Ux2'><fieldset id='l5Ux2'></fieldset></dl></div>

    <small id='l5Ux2'></small><noframes id='l5Ux2'>

          <bdo id='l5Ux2'></bdo><ul id='l5Ux2'></ul>

      1. <legend id='l5Ux2'><style id='l5Ux2'><dir id='l5Ux2'><q id='l5Ux2'></q></dir></style></legend>
      2. 为什么有时会跳过 maven 依赖项中的版本号?

        时间:2023-07-14

        <small id='kUNAd'></small><noframes id='kUNAd'>

              <tbody id='kUNAd'></tbody>
          1. <tfoot id='kUNAd'></tfoot>

              • <bdo id='kUNAd'></bdo><ul id='kUNAd'></ul>
                <legend id='kUNAd'><style id='kUNAd'><dir id='kUNAd'><q id='kUNAd'></q></dir></style></legend>
                • <i id='kUNAd'><tr id='kUNAd'><dt id='kUNAd'><q id='kUNAd'><span id='kUNAd'><b id='kUNAd'><form id='kUNAd'><ins id='kUNAd'></ins><ul id='kUNAd'></ul><sub id='kUNAd'></sub></form><legend id='kUNAd'></legend><bdo id='kUNAd'><pre id='kUNAd'><center id='kUNAd'></center></pre></bdo></b><th id='kUNAd'></th></span></q></dt></tr></i><div id='kUNAd'><tfoot id='kUNAd'></tfoot><dl id='kUNAd'><fieldset id='kUNAd'></fieldset></dl></div>

                  本文介绍了为什么有时会跳过 maven 依赖项中的版本号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我对 maven 的功能还很陌生..我已经看到在放置依赖项的 pom.xml 中,有时只提到了 groupID 和 artifact id 并且跳过了版本.为什么是这样?例如以下依赖来自 springsource 网站 http://spring.io/guides/gs/authenticating-ldap/

                  I am fairly new to maven's capabilities.. I have seen that in pom.xml where dependencies are put, at times, only groupID and artifact id are mentioned and version is skipped. why is this? For example the below dependency is from springsource website http://spring.io/guides/gs/authenticating-ldap/

                  <dependencies>
                      <dependency>
                          <groupId>org.springframework.boot</groupId>
                          <artifactId>spring-boot-starter-web</artifactId>
                      </dependency>
                      <dependency>
                          <groupId>org.springframework.boot</groupId>
                          <artifactId>spring-boot-starter-security</artifactId>
                      </dependency>
                      <dependency>
                          <groupId>org.springframework.security</groupId>
                          <artifactId>spring-security-ldap</artifactId>
                          <version>3.2.4.RELEASE</version>
                      </dependency>
                      <dependency>
                          <groupId>org.apache.directory.server</groupId>
                          <artifactId>apacheds-server-jndi</artifactId>
                          <version>1.5.5</version>
                      </dependency>
                  </dependencies>
                  

                  但在 stackoverflow 的其他地方也提到版本不是可选的.如果有人能解释这一点,我会很高兴.

                  But elsewhere in stackoverflow it was also mentioned that version is not optional. I would be glad if someone could explain this.

                  推荐答案

                  是的,版本不是可选的.

                  Yes, version is not optional.

                  考虑一个多模块应用程序,它有 10 个模块,比如 module1、module2..module10.假设所有这 10 个项目都使用 spring-boot-starter-web.如果这 10 个模块相互依赖,您可能希望在这 10 个模块中使用相同版本的 spring-boot-starter-web.

                  Consider a multimodule application which has 10 modules, say module1, module2.. module10.Assume that all of these 10 projects use the spring-boot-starter-web. In case these 10 modules are interdependent, you might want to use the same version of the spring-boot-starter-web in each of these 10.

                  现在想象一下,如果您要在所有这 10 个 pom 文件中保持相同的版本号,然后当您想使用更新版本的 spring-boot-starter 时更新所有这些文件,那将是多么复杂-网络.如果可以集中管理这些信息不是更好吗?

                  Now just imagine how complicated it would be if you were to maintain the same version number in all of these 10 pom files and then update all of them when you want to use a newer version of spring-boot-starter-web. Wouldn't it be better if this information can be managed centrally?

                  Maven 有一个已知的 <dependencyManagement/> 标签来解决这个问题并集中依赖信息.

                  Maven has got something known a <dependencyManagement/> tag to get around this and centralize dependency information.

                  对于您提供的示例,下面的一组链接将帮助您了解如何解析版本号,即使它不存在于您正在查看的 pom 中.

                  For the example which you have provided, below set of links will help you understand how the version number is resolved even though it's not present in the pom which you are looking at.

                  查看你正在查看的 pom 的父标签 (https://github.com/spring-guides/gs-authenticating-ldap/blob/master/complete/pom.xml)

                  Look at the parent tag of the pom you are looking at (https://github.com/spring-guides/gs-authenticating-ldap/blob/master/complete/pom.xml)

                  现在让我们去那个父节点看看版本是否在那个 pom 的依赖管理部分中指定(https://github.com/spring-projects/spring-boot/blob/master/spring-boot-starters/spring-boot-starter-parent/pom.xml).不,它也没有在那里定义.现在让我们看看父母的父母.https://github.com/spring-projects/spring-boot/blob/master/spring-boot-dependencies/pom.xml.哦,是的,我们那里有版本号.

                  Now lets go to that parent and see if the versions are specified in the dependencyManagement section of that pom(https://github.com/spring-projects/spring-boot/blob/master/spring-boot-starters/spring-boot-starter-parent/pom.xml). No it's not defined there as well. Now lets look at the parent of parent. https://github.com/spring-projects/spring-boot/blob/master/spring-boot-dependencies/pom.xml. Oh yea, we have got the version numbers there.

                  类似于dependencyManagement,插件可以在pom的pluginManagement部分进行管理.

                  Similar to dependencyManagement, plugins can be managed in the pluginManagement section of the pom.

                  希望能解释一下.

                  参考:dependencyManagement, 插件管理

                  这篇关于为什么有时会跳过 maven 依赖项中的版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:查找丢失的 Maven 工件 下一篇:Maven-shade-plugin、uber-jar 和重叠类

                  相关文章

                  <tfoot id='ljtdz'></tfoot>

                • <legend id='ljtdz'><style id='ljtdz'><dir id='ljtdz'><q id='ljtdz'></q></dir></style></legend>
                    <i id='ljtdz'><tr id='ljtdz'><dt id='ljtdz'><q id='ljtdz'><span id='ljtdz'><b id='ljtdz'><form id='ljtdz'><ins id='ljtdz'></ins><ul id='ljtdz'></ul><sub id='ljtdz'></sub></form><legend id='ljtdz'></legend><bdo id='ljtdz'><pre id='ljtdz'><center id='ljtdz'></center></pre></bdo></b><th id='ljtdz'></th></span></q></dt></tr></i><div id='ljtdz'><tfoot id='ljtdz'></tfoot><dl id='ljtdz'><fieldset id='ljtdz'></fieldset></dl></div>

                      <small id='ljtdz'></small><noframes id='ljtdz'>

                      • <bdo id='ljtdz'></bdo><ul id='ljtdz'></ul>