简体   繁体   English

Maven如何在Spring Tool Suite中自动从父pom.xml继承属性

[英]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.

相关问题 Maven不解析父pom.xml文件中的属性 - Maven does not resolve properties from parent pom.xml file Maven的。 如何从paren pom.xml继承配置文件? - Maven. How to inherit profile from paren pom.xml? 在spring工具套件中,我们使用pom.xml添加了maven依赖,但是如图所示形状不一样,这是为什么呢? - In the spring tool suite, we added maven dependencies using pom.xml, but the shape is different as shown in the picture, why is that? 位于 xsi:schemaLocation 的 pom.xml 中的 Spring Tool Suite Maven 项目错误 - Spring Tool Suite Maven project error in pom.xml at xsi:schemaLocation 向 pom.xml 文件添加依赖后,Spring Tool Suite 自动关闭 - Spring Tool Suite Closes Automatically after adding dependency to pom.xml file 如何在 Maven pom.xml 中重用 application.properties (Spring Boot) 中的属性? - How to reuse properties from application.properties (Spring Boot) in Maven pom.xml? 如何从父pom.xml的配置文件中提取属性数据? - How to extract properties data from a profile in a parent pom.xml? Maven pom.xml Spring Boot 不存在 - Maven pom.xml Spring Boot does not exist Maven读取.properties以在pom.xml中使用 - Maven read .properties to use in pom.xml 如何使用 maven pom.xml 或 in.properties 文件中其他文件的变量? - How to use variables from other file in maven pom.xml or in .properties file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM