当前位置:网站首页>pom. XML configuration file label: differences between dependencies and dependencymanagement
pom. XML configuration file label: differences between dependencies and dependencymanagement
2022-07-07 20:00:00 【Whiteye too white】
dependencyManagement Dependency management
Usually in the top-level parent of a project pom Use in dependencyManagement,
Use pom.xml Medium dependencyManagement Element allows all subprojects to reference a dependency without listing the version number . In this way, the dependent version number in the child project will use the parent project pom The dependent version in the file .
When a dependency of a subproject does not specify a version number ,maven Will go up the father and son level , Until you find someone who has dependencyManagement Elements of the project , And then it will use this dependencyManagement The version specified in the element .
The good thing is : If multiple subprojects refer to the same dependency , You can avoid declaring a version number in each used subproject , So when you want to upgrade or switch to another version , Just update in the top-level parent container , It doesn't need to be modified one by one ; In addition, if a sub project requires another version , You just need to be yourself pom Just state the version number in .
Be careful :
- dependencyManagement It's just a statement of dependency , No introduction , So the child project needs to display the required dependencies for the declaration
- If you don't declare dependencies in subprojects , Is not inherited from the parent project ; Only the dependency is written in the subproject , And no specific version was specified , Will inherit the item from the parent project , also version and scope Read from parent pom.
- If the version number is specified in the subproject , Then you will use the... Specified in the subproject jar edition .
dependencies Dependency relationship
Introduce automatic declaration in dependencies All the dependencies in , It is inherited by all subprojects by default . If no dependencies are written in the project , From the parent project
Inherit ( All properties inherit ) Declared in the parent project dependencies Dependencies in .
1. Single module
<!-- Just manage the version number , It won't actually introduce jar-->
<dependencyManagement>
<dependencies>
<dependency>
<!--jar Package identity limit -->
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<!-- Declaration of version number -->
<version>3.2.7</version>
</dependency>
</dependencies>
</dependencyManagement>
<!-- Will actually download the declared dependencies jar package -->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<!-- Do not declare version label , Will inherit dependencyManagement-->
</dependency>
</dependencies>
2. Multi module situation
Parent module pom.xml
<!--parent-module Parent module pom.xml-->
<properties>
<!-- Unified management jar Package version . Focus on the parent module properties All dependent version numbers are defined in the tag .-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.eclipse.persistence.jpa.version>1.2.6</org.eclipse.persistence.jpa.version>
<javaee-api.version>1.8</javaee-api.version>
</properties>
<dependencyManagement>
<!-- Define the version number of the public dependency -->
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>${org.eclipse.persistence.jpa.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee-api.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Sub module pom.xml
<!--son-module Sub module pom.xml-->
<!-- Inherited parent class -->
<parent>
<!-- Declare the identity information of the parent class -->
<artifactId>parent-module</artifactId>
<groupId>com.ppd</groupId>
<version>0.0.1-SNAPSHOT</version>
<!-- Declare the of the parent class pom File path -->
<relativePath>../parent-module/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>son-module</artifactId>
<packaging>ejb</packaging>
<!-- Dependency relationship -->
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<!-- If not declared, inherit the parent class version、scope-->
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<!-- Declaration does not inherit the parent class version-->
<version>1.8<version/>
<!-- Inherited parent class scope-->
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<!-- If not declared, inherit the parent class version-->
<scope>provided</scope>
</dependency>
</dependencies>
边栏推荐
- Kirin Xin'an with heterogeneous integration cloud financial information and innovation solutions appeared at the 15th Hunan Financial Technology Exchange Conference
- “本真”是什么意思
- LeetCode_ 7_ five
- 让这个 CRMEB 单商户微信商城系统火起来,太好用了!
- 开源重器!九章云极DataCanvas公司YLearn因果学习开源项目即将发布!
- ASP.NET体育馆综合会员管理系统源码,免费分享
- 831. KMP字符串
- 注解。。。
- Browse the purpose of point setting
- 8 CAS
猜你喜欢

位运算介绍

Cloud 组件发展升级
Make this crmeb single merchant wechat mall system popular, so easy to use!

Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse

CSDN语法说明

关于ssh登录时卡顿30s左右的问题调试处理

Install mysql8 for Linux X ultra detailed graphic tutorial

使用高斯Redis实现二级索引

9 atomic operation class 18 Rohan enhancement

Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
随机推荐
2022年投资哪个理财产品收益高?
R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化分组密度图、使用stat_overlay_normal_density函数为每个分组的密度图叠加正太分布曲线
怎么在手机上买股票开户 股票开户安全吗
爬虫实战(七):爬王者英雄图片
ant desgin 多选
Notes...
R语言ggplot2可视化:使用ggpubr包的ggqqplot函数可视化QQ图(Quantile-Quantile plot)
Unable to link the remote redis server (solution 100%
Implement secondary index with Gaussian redis
Kirin Xin'an cloud platform is newly upgraded!
torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
R语言fpc包的dbscan函数对数据进行密度聚类分析、查看所有样本的聚类标签、table函数计算聚类簇标签与实际标签构成的二维列联表
openEuler 资源利用率提升之道 01:概论
841. 字符串哈希
ASP. Net gymnasium integrated member management system source code, free sharing
ASP. Net kindergarten chain management system source code
R language ggplot2 visualization: use the ggdensity function of ggpubr package to visualize the packet density graph, and use stat_ overlay_ normal_ The density function superimposes the positive dist
torch.nn.functional.pad(input, pad, mode=‘constant‘, value=None)记录
Browse the purpose of point setting
【STL】vector