關(guān)于Maven parent.relativePath說(shuō)明
Maven parent.relativePath說(shuō)明
關(guān)于Maven非?;A(chǔ)的問(wèn)題
Maven parent.relativePath 的意思,很多人網(wǎng)上搜索 類(lèi)似下面pom.xml中的問(wèn)題 ,文件中的
<relativePath /> <!-- lookup parent from repository -->
是什么意思?
<parent> <groupId>com.middol</groupId> <artifactId>webbase-dependency-management</artifactId> <version>1.0-SNAPSHOT</version> <relativePath/> <!-- lookup parent from repository --> </parent>
網(wǎng)上大多數(shù)回到如下:
- 設(shè)定一個(gè)空值將始終從倉(cāng)庫(kù)中獲取,不從本地路徑獲取,如<relativePath />
- Maven parent.relativePath
- 默認(rèn)值為../pom.xml
- 查找順序:relativePath元素中的地址–本地倉(cāng)庫(kù)–遠(yuǎn)程倉(cāng)庫(kù)
部分 Java 菜鳥(niǎo)或是一部分老鳥(niǎo)竟然也懵
答案第一行 :
設(shè)定一個(gè)空值將始終從倉(cāng)庫(kù)中獲取,不從本地路徑獲取,如<relativePath />
然后又開(kāi)始問(wèn) : 倉(cāng)庫(kù) 是哪一個(gè)倉(cāng)庫(kù) ?。?/strong>
我就納悶了搜什么百度,自己測(cè)試一下不就好了嗎,另外直接點(diǎn)擊進(jìn)去看原生說(shuō)明啊,下面是 xml 原生英文解釋?zhuān)?/p>
<xs:element name="relativePath" minOccurs="0" type="xs:string" default="../pom.xml"> <xs:annotation> <xs:documentation source="version">4.0.0</xs:documentation> <xs:documentation source="description"> The relative path of the parent <code>pom.xml</code> file within the check out. The default value is <code>../pom.xml</code>. Maven looks for the parent pom first in the reactor of currently building projects, then in this location on the filesystem, then the local repository, and lastly in the remote repo. <code>relativePath</code> allows you to select a different location, for example when your structure is flat, or deeper without an intermediate parent pom. However, the group ID, artifact ID and version are still required, and must match the file in the location given or it will revert to the repository for the POM. This feature is only for enhancing the development in a local checkout of that project. </xs:documentation> </xs:annotation> </xs:element>
讀一讀英文,不行字典翻譯翻譯,然后自己做下實(shí)驗(yàn) 得出如下結(jié)論:
- relativePath 是Maven為了尋找父模塊pom.xml所額外增加的一個(gè)尋找路徑
- relativePath 默認(rèn)值為 …/pom.xml
Maven尋找父模塊pom.xml的順序
如下:
(1) first in the reactor of currently building projects
這里一個(gè)maven概念 反應(yīng)堆(reactor ),意思就是先從工程里面有依賴(lài)相關(guān)的模塊中找你引入的parent 的pom.xml,
(2) then in this location on the filesystem
然后從 你定義的 <relativePath > 路徑中找,當(dāng)然你如果只是 / 即空值,則跳過(guò)該步驟,默認(rèn)值 ../pom.xml 則是從上級(jí)目錄中找啦。
(3) then the local repository
這個(gè)就不說(shuō)了,如果 (1) (2) 步驟沒(méi)有則從 本地倉(cāng)庫(kù)找啦。
(4) and lastly in the remote repo
這個(gè)還用說(shuō)嗎,上面都找不到了,最后只能從遠(yuǎn)程倉(cāng)庫(kù)找啦,再找不到就報(bào)錯(cuò)給你看
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Springboot?maven項(xiàng)目配置文件覆蓋問(wèn)題的處理
這篇文章主要介紹了Springboot?maven項(xiàng)目配置文件覆蓋問(wèn)題的處理方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-05-05MyBatis-Plus找不到Mapper.xml文件的幾種解決方法
mybatis-plus今天遇到一個(gè)問(wèn)題,就是mybatis 沒(méi)有讀取到mapper.xml 文件,所以下面這篇文章主要給大家介紹了關(guān)于MyBatis-Plus找不到Mapper.xml文件的幾種解決方法,需要的朋友可以參考下2022-06-06如何通過(guò)javacv實(shí)現(xiàn)圖片去水印(附代碼)
這篇文章主要介紹了如何通過(guò)javacv實(shí)現(xiàn)圖片去水?。ǜ酱a),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-07-07Java使用同步方法解決銀行取錢(qián)的安全問(wèn)題案例分析
這篇文章主要介紹了Java使用同步方法解決銀行取錢(qián)的安全問(wèn)題,結(jié)合具體案例形式分析了java同步方法實(shí)現(xiàn)多線程安全操作銀行取錢(qián)問(wèn)題,需要的朋友可以參考下2019-09-09解決springboot中mongodb不啟動(dòng)及Dao不能被掃描到的問(wèn)題
這篇文章主要介紹了解決springboot中mongodb不啟動(dòng)及Dao不能被掃描到的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-05-05SpringBoot詳細(xì)分析自動(dòng)裝配原理并實(shí)現(xiàn)starter
相對(duì)于傳統(tǒng)意義上的Spring項(xiàng)目,SpringBoot具有開(kāi)箱即用,簡(jiǎn)化配置,內(nèi)置Tomcat等等等等一系列的特點(diǎn)。在這些特點(diǎn)中,最重要的兩條就是約定優(yōu)于配置和自動(dòng)裝配2022-07-07SpringBoot中@MessageMapping注解的原理及使用詳解
這篇文章主要介紹了SpringBoot中@MessageMapping注解的原理及使用詳解,@MessageMapping注解是Spring Boot提供的一個(gè)重要的注解之一,它可以幫助我們處理WebSocket消息,需要的朋友可以參考下2023-07-07原生java代碼實(shí)現(xiàn)碼云第三方驗(yàn)證登錄的示例代碼
這篇文章主要介紹了原生java代碼實(shí)現(xiàn)碼云第三方驗(yàn)證登錄的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04