maven scope import

1
2
3
4
5
6
7
8
9
10
11
12
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.12.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

我们看到,这里多了一个<scope>import</scope>,它的意思是将spring-boot-dependencies 中dependencyManagement的dependencies,全部引入到当前工程的dependencyManagement中。根据maven官方文档Dependency Scope http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

  • import
    This scope is only supported on a dependency of type pom in the <dependencyManagement> section. It indicates the dependency is to be replaced with the effective list of dependencies in the specified POM's <dependencyManagement> section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.

参考:https://blog.csdn.net/wangjun5159/article/details/104298131

http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html