Ram*_*ama 3 java dependencies pom.xml maven
我对maven的功能还很陌生。.我已经看到在放置依赖项的pom.xml中,有时仅提及groupID和工件ID,而跳过版本。为什么是这样?例如,以下依赖项来自springsource网站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>
Run Code Online (Sandbox Code Playgroud)
但是在stackoverflow的其他地方,也提到版本不是可选的。如果有人可以解释我会很高兴。
是的,版本不是可选的。
考虑一个具有10个模块的多模块应用程序,例如module1,module2..module10。假定所有这10个项目都使用spring-boot-starter-web。如果这10个模块是相互依赖的,则您可能需要在这10个模块spring-boot-starter-web中的每一个中使用相同的版本。
现在,想像一下,如果要在所有这10个pom文件中都保持相同的版本号,然后在要使用.pm的较新版本时更新所有这些文件,将会有多么复杂spring-boot-starter-web。如果可以集中管理此信息,会更好吗?
Maven有一个已知的<dependencyManagement/>标签可以解决这个问题并集中化依赖性信息。
对于您提供的示例,下面的链接集将帮助您了解如何解析版本号,即使您查看的pom中不存在该版本号也是如此。
查看您正在查看的pom的父标签(https://github.com/spring-guides/gs-authenticating-ldap/blob/master/complete/pom.xml)
现在让我们转到该父级,看看是否在该pom的dependencyManagement部分中指定了版本(https://github.com/spring-projects/spring-boot/blob/master/spring-boot-starters/spring-boot -starter-parent / pom.xml)。不,它在那里也没有定义。现在,让我们看一下parent的父级。https://github.com/spring-projects/spring-boot/blob/master/spring-boot-dependencies/pom.xml。哦,是的,我们那里有版本号。
与dependencyManagement类似,可以在pom的pluginManagement部分中管理插件。
希望能解释一下。
请参阅:dependencyManagement,pluginManagement