栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot依赖管理详解

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot依赖管理详解

一,SpringBoot导入dependency不需要指定版本

在开发过程中,SpringBoot项目会导入一个父类的dependency,这个依赖是需要去指定一个统一版本的,而这个版本根据实际开发而变更

 
     org.springframework.boot
     spring-boot-starter-parent<11./artifactId>
     2.2.2.RELEASE
      
 

从这用鼠标左键+ctrl点入,发现在parent的底层还有一个依赖:Spring-boot-dependencies


     org.springframework.boot
     spring-boot-dependencies
     2.2.2.RELEASE
     ../../spring-boot-dependencies

同样的方法继续点入进去,发现会对一些常用的依赖文件进行了版本号的限定,比如mysql,activemq,solr,tomcat.....。而这些则与最上层的SpringBoot2.2的版本像绑定,减少了在搭建环境时因为依赖版本冲突不匹配等问题导致运行失败。


     5.15.11
     ...
     8.2.0
     8.0.18
     2.3.1
     2.2.2.RELEASE
     2.0.4.RELEASE
     1.2.4.RELEASE
     5.2.1.RELEASE
     Corn-RELEASE
     3.0.8.RELEASE
     3.28.0
     ${jakarta-mail.version}
     9.0.29
     3.0.11.RELEASE
     2.0.1
     ...
 
二,SpringBoot启动项目运行的jar包依赖

这了简单举个例子,在SpringBoot用到了Spring表现层的Controller,那么势必引用了SpringMVC相关的依赖,那么这是在哪儿引用进来的?使用MVC,SpringBoot需要去引入spring-boot-starter-web依赖,这个依赖点进去。

以下为spring-boot-starter-webׁ引入依赖部分


     
         org.springframework.boot
         spring-boot-starter
         2.2.2.RELEASE
         compile
     
     
         org.springframework.boot
         spring-boot-starter-json
         2.2.2.RELEASE
         compile
         
     
         org.springframework.boot
         spring-boot-starter-tomcat
         2.2.2.RELEASE
         compile
     
     
         org.springframework.boot
         spring-boot-starter-validation
         2.2.2.RELEASE
         compile
         
             
                 tomcat-embed-el
                 org.apache.tomcat.embed
             
         
     
     
         org.springframework
         spring-web
         5.2.2.RELEASE
         compile
     
     
         org.springframework
         spring-webmvc
         5.2.2.RELEASE
         compile
     

而且不仅仅是web-started,SpringBoot的官方文档中同样提供了其它场景下开发的启动器

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/269963.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号