SpringBoot Pom文件依賴及Starter啟動(dòng)器詳細(xì)介紹
Pom文件的依賴
我們進(jìn)入POM文件,首先是看到的是Pom文件中的parent
parent是Spring Boot的框架版本控制中心
<!-- 導(dǎo)入springboot版本和框架依賴 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.6.3</version> <relativePath></relativePath> </parent>
點(diǎn)進(jìn)去看一下parent是如何控制版本的。點(diǎn)進(jìn)去之后,發(fā)現(xiàn)它也有一個(gè)父工程
它的父工程為spring-boot-dependencies,看到名字應(yīng)該想到,是springboot的依賴。同時(shí)還有其他東西。再點(diǎn)進(jìn)去,看到里面有<dependencyManagement>
,管理各種依賴的版本。
到這里就差不多理解了parent是如何控制版本的。
我們創(chuàng)建的springboot
工程是spring-boot-start-parent
的子工程,spring-boot-starter-parent
是spring-boot-denpendencies
的子工程,父工程通過dependencyManagement
控制了各種依賴的版本。所以當(dāng)子工程導(dǎo)入依賴時(shí),可以不寫版本,自動(dòng)使用父工程規(guī)定的版本,以此來進(jìn)行版本的控制。
spring-boot場(chǎng)景啟動(dòng)器
starter:spring-boot場(chǎng)景啟動(dòng)器
我們以web啟動(dòng)器為例:
<!-- 導(dǎo)入動(dòng)態(tài)web場(chǎng)景啟動(dòng)器 --> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
我們還是點(diǎn)進(jìn)去看到spring-boot-starter-web的內(nèi)容:
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>2.6.3</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-json</artifactId> <version>2.6.3</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <version>2.6.3</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>5.3.15</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.3.15</version> <scope>compile</scope> </dependency> </dependencies>
可以看到里面集成了web開發(fā)的其他依賴,也就是說通過添加Spring-boot-starter-web
依賴,它就導(dǎo)入了web環(huán)境所有的依賴,只需導(dǎo)入starter,可自動(dòng)導(dǎo)入web模塊正常運(yùn)行所依賴的組件。其他的starter也是一樣的。
springboot出廠默認(rèn)就寫好了很多starter,如:
spring-boot-starter-activemq,spring-boot-starter-aop,spring-boot-starter-data-redis,spring-boot-starter-data-solr等
重要提示:Spring Boot將所有的絕大部分框架整合場(chǎng)景都進(jìn)行了抽取,做成一個(gè)個(gè)的starters(啟動(dòng)器),只需要在項(xiàng)目里面引入這些starter相關(guān)整合所需的依賴都會(huì)導(dǎo)入進(jìn)來。
到此這篇關(guān)于SpringBoot Pom文件依賴及Starter啟動(dòng)器詳細(xì)介紹的文章就介紹到這了,更多相關(guān)SpringBoot Pom文件依賴內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
SpringCloud之consul服務(wù)注冊(cè)與發(fā)現(xiàn)、配置管理、配置持久化方式
這篇文章主要介紹了SpringCloud之consul服務(wù)注冊(cè)與發(fā)現(xiàn)、配置管理、配置持久化方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2025-03-03idea中如何過濾某些文件不提交的方法實(shí)現(xiàn)
本文主要介紹了idea中如何過濾某些文件不提交,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07IDEA2020.1創(chuàng)建springboot項(xiàng)目(國內(nèi)腳手架)安裝lombok
這篇文章主要介紹了IDEA2020.1創(chuàng)建springboot項(xiàng)目(國內(nèi)腳手架)安裝lombok,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06Java設(shè)置session超時(shí)的幾種方式總結(jié)
這篇文章主要介紹了Java設(shè)置session超時(shí)的幾種方式總結(jié)的相關(guān)資料,需要的朋友可以參考下2017-07-07spring+Jpa多數(shù)據(jù)源配置的方法示例
這篇文章主要介紹了spring+Jpa多數(shù)據(jù)源配置的方法示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-08-08