文章摘要: 问题答疑。
在pom文件中引入spring boot父极时使用的是<parent>标签引入且写在文件开头位置
相关信息
个人理解
- 因为Maven中在创建子模块时,就是使用
<parent>标签的方式写在pom.xml文件开头位置。这种方式比较清晰明了,因此推荐该方式。 - 而使用
<dependency>标签作为依赖引入,需要将其写在靠前位置,因为依赖有加载顺序。
使用<parent>标签写在开头位置的方案
<!--继承父级项目-->
<parent> <!--引入并继承spring boot提供的父级pom.xml-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
</parent>
使用<dependency>标签作为依赖引入的方案
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>