[英]How does Maven automatically inherit properties from parent pom.xml in Spring Tool Suite
I am not sure whether I have understood inheritance in Maven pom.xml
correctly or not. 我不确定我是否正确理解了Maven pom.xml
继承。 From my understanding I have to define common properties in Parent pom.xml
, then in Child project those properties can be inherited. 根据我的理解,我必须在Parent pom.xml
定义公共属性,然后在Child项目中可以继承那些属性。
My confusion started when I created a new Maven project using Spring Tool Suite IDE. 当我使用Spring Tool Suite IDE创建一个新的Maven项目时,我的困惑就开始了。 I created a project through File → New → Spring Started Project. 我通过文件→新建→Spring Started Project创建了一个项目。 I got the base folder structure created for Maven with default pom.xml
. 我得到了使用默认pom.xml
为Maven创建的基本文件夹结构。 When I analysed the default pom.xml
, it has the following parent tag: 当我分析默认的pom.xml
,它具有以下父标记:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
I have not defined any parent pom.xml
. 我尚未定义任何父pom.xml
。 I am wondering from which parent pom the above attributes are reference? 我想知道以上属性是从哪个父pom引用的?
Note: I am using STS embedded Maven. 注意:我正在使用STS嵌入式Maven。
As you can see, the maven artifact spring-boot-starter-parent
from the group org.springframework.boot
in version 1.5.7.RELEASE
is set to be your parent. 如您所见,版本1.5.7.RELEASE
org.springframework.boot
组中的Maven工件spring-boot-starter-parent
被设置为您的父代。 The same way a dependency would be searched for, the parent is searched for... so you probably don't have this parent in your local maven repository, so maven central is called (the same way maven central would be called to find slf4j, hibernate or any other referenced dependency). 搜索依赖项的方式相同,搜索父项的方式...因此您可能在本地Maven存储库中没有该父项,因此调用了Maven Central(将使用调用Maven Central的方式来查找slf4j ,休眠或任何其他引用的依赖项)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.