新建springboot子模塊時,pom文件project根標簽會報紅


現象

project根標簽報錯

新建一個springboot的子模塊的時候,此時parent是spring-boot-starter-parent,然后pom文件project根標簽經常會報紅

解決方法

parent標簽里面加上屬性

        <relativePath></relativePath>

截圖:

原因

因為實際上springboot子模塊真正的parent是spring-boot-starter-parent,但是貌似這個模塊又是你現在項目的子模塊,好像有些許關聯

但其實你子模塊加上parent,並不會完全跟你現在根項目沒關系,如果你沒有加上relativePath,maven還是會默認去找子模塊目錄下的pom文件對應的項目為父親模塊。

但是只是加上relativePath為空就沒事了,他就回去找遠程的pom文件對象的項目為父親模塊

relativePath的解釋

The relative path of the parent pom.xml file within the check out. If not specified, it defaults to ../pom.xml. Maven looks for the parent POM first in this location on the filesystem, then the local repository, and lastly in the remote repo. relativePath 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. Set the value to an empty string in case you want to disable the feature and always resolve the parent POM from the repositories.
Default value is: ../pom.xml.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM