SpringBoot实用小知识之Maven中dependencys和dependencymanagement区别

简介:       利用pom管理引用包时,如果是单项目的话就直接在dependencies引用了,若有一个大工程项目里面包含多个子模块,则为了所有项目模块包的版本统一和好管理,则需要用到dependencyManagement,但两者使用场景有所区别。

      利用pom管理引用包时,如果是单项目的话就直接在dependencies引用了,若有一个大工程项目里面包含多个子模块,则为了所有项目模块包的版本统一和好管理,则需要用到dependencyManagement,但两者使用场景有所区别。

dependencies

  dependencies即使在子项目中不写该依赖项,那么子项目仍然会从父项目中继承该依赖项(全部继承)。

dependencyManagement

  dependencyManagement里只是声明依赖,并不实现引入,因此子项目需要显示的声明需要用的依赖。如果不在子项目中声明依赖,是不会从父项目中继承下来的;只有在子项目中写了该依赖项,并且没有指定具体版本,才会从父项目中继承该项,并且version和scope都读取自父pom;这样就可以统一全部项目的版本号;

  另外如果子项目中指定了版本号,那么会使用子项目中指定的jar版本。

目录
相关文章
|
2月前
|
Java 程序员 API
Springboot-swagger配置(idea社区版2023.1.4+apache-maven-3.9.3-bin)
Springboot-swagger配置(idea社区版2023.1.4+apache-maven-3.9.3-bin)
58 1
|
2月前
|
前端开发 Java 数据库连接
Springboot-MyBatis配置-配置端口号与服务路径(idea社区版2023.1.4+apache-maven-3.9.3-bin)
Springboot-MyBatis配置-配置端口号与服务路径(idea社区版2023.1.4+apache-maven-3.9.3-bin)
33 0
|
2月前
|
JSON Java Maven
SpringBoot使用git-commit-id-maven-plugin打包
【2月更文挑战第1天】 git-commit-id-maven-plugin 是一个maven 插件,用来在打包的时候将git-commit 信息打进jar中。 这样做的好处是可以将发布的某版本和对应的代码关联起来,方便查阅和线上项目的维护。至于它的作用,用官方说法,这个功能对于大型分布式项目来说是无价的。
84 0
|
2月前
|
安全 前端开发 程序员
Springboot-EolinkApikit一键生成注释与一键上传API接口(idea社区版2023.1.4+apache-maven-3.9.3-bin)
Springboot-EolinkApikit一键生成注释与一键上传API接口(idea社区版2023.1.4+apache-maven-3.9.3-bin)
18 0
|
2月前
|
Java API Maven
Springboot快速搭建跨域API接口(idea社区版2023.1.4+apache-maven-3.9.3-bin)
Springboot快速搭建跨域API接口(idea社区版2023.1.4+apache-maven-3.9.3-bin)
33 0
|
2月前
|
Java Linux Apache
Maven的Binary与Source区别
Maven的Binary与Source区别
41 1
|
2月前
|
JavaScript Java Apache
【SpringBoot】Maven 版本管理与 flatten-maven-plugin 插件的使用及分析
【SpringBoot】Maven 版本管理与 flatten-maven-plugin 插件的使用及分析
170 0
|
2月前
|
XML Java 测试技术
【SpringBoot】基于 Maven 的 pom.xml 配置详解
【SpringBoot】基于 Maven 的 pom.xml 配置详解
204 0
【SpringBoot】基于 Maven 的 pom.xml 配置详解
SpringBoot中maven项目打包时出现的问题
SpringBoot中maven项目打包时出现的问题
SpringBoot中maven项目打包时出现的问题
SpringBoot中maven项目打包时出现的问题
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project demo: Fatal error compiling
SpringBoot中maven项目打包时出现的问题