溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

springboot多模塊開發(fā)并使用dependencyManagement管理的方法

發(fā)布時(shí)間:2022-04-07 10:35:55 來源:億速云 閱讀:546 作者:iii 欄目:編程語言

今天小編給大家分享一下springboot多模塊開發(fā)并使用dependencyManagement管理的方法的相關(guān)知識(shí)點(diǎn),內(nèi)容詳細(xì),邏輯清晰,相信大部分人都還太了解這方面的知識(shí),所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。

當(dāng)我們新建一個(gè)springboot項(xiàng)目時(shí),pom.xml中會(huì)有一個(gè)parent

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

這是我們常見的一個(gè),其實(shí)還有另外一種使用方式,具體可參考官方文檔

<dependencyManagement>
	<dependencies>
		<dependency>
			<!-- Import dependency management from Spring Boot -->
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-dependencies</artifactId>
			<version>2.4.4</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>

這種方式在多模塊開發(fā)中用的比較多,使用dependencyManagement,它的 type 是 pom,scope 是 import,這種類型的 dependency 只能在 dependencyManagement 標(biāo)簽中聲明,然后在子模塊中使用dependency引用即可。并且這樣能做到,在哪個(gè)模塊中需要哪個(gè)就用哪個(gè),不需要不引用即可。不會(huì)全部導(dǎo)入。

點(diǎn)擊:spring-boot-starter-parent會(huì)發(fā)現(xiàn)他里面又有一個(gè)parent,而這個(gè)parent和我們上面那種import的竟然是完全一樣的

springboot多模塊開發(fā)并使用dependencyManagement管理的方法

最終都會(huì)spring-boot-dependencies里面

springboot多模塊開發(fā)并使用dependencyManagement管理的方法

以上就是“springboot多模塊開發(fā)并使用dependencyManagement管理的方法”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會(huì)為大家更新不同的知識(shí),如果還想學(xué)習(xí)更多的知識(shí),請(qǐng)關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI