maven中使用scope= import
最新推荐文章于 2025-03-06 17:53:56 发布

leoxyk 于 2018-03-20 13:18:39 发布
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
在Spring boot 项目的POM文件中,我们可以通过在POM文件中继承 Spring-boot-starter-parent来引用Srping boot默认依赖的jar包,如下:
1
2<parent>
3<groupId>org.springframework.boot</groupId>
4<artifactId>spring-boot-starter-parent</artifactId>
5<version>2.0.1.BUILD-SNAPSHOT</version>
6</parent>
但是,通过上面的parent继承的方法,只能继承一个 spring-boot-start-parent。实际开发中,用户很可能需要继承自己公司的标准parent配置,这个时候可以使用 scope=import 来实现多继承。
代码如下:
1<dependencyManagement>
2<dependencies>
3<dependency>
4
5<groupId>org.springframework.boot</groupId>
6<artifactId>spring-boot-dependencies</artifactId>
7<version>2.0.1.BUILD-SNAPSHOT</version>
8<type>pom</type>
9<scope>import</scope>
10</dependency>
11</dependencies>
12</dependencyManagement>
通过上面方式,就可以获取spring-boot-dependencies.2.0.1.BUILD-SNAPSHOT.pom文件中dependencyManagement配置的jar包依赖。
如果要继承多个,可以在dependencyManagement中添加,如:
1<dependencyManagement>
2<dependencies>
3
4<dependency>
5<groupId>org.springframework.data</groupId>
6<artifactId>spring-data-releasetrain</artifactId>
7<version>Fowler-SR2</version>
8<type>pom</type>
9<scope>import</scope>
10</dependency>
11<dependency>
12<groupId>org.springframework.boot</groupId>
13<artifactId>spring-boot-dependencies</artifactId>
14<version>2.0.1.BUILD-SNAPSHOT</version>
15<type>pom</type>
16<scope>import</scope>
17</dependency>
18</dependencies>
19</dependencyManagement>
相关知识
maven中scope=compile 和 provided区别
在 Spring Boot 中使用 Logback 和 Log4j2 记录日志
ImportError: cannot import name 'is
maven使用mvn archetype:generate命令创建项目骨架遇到的问题
TensorFlow猫狗大战完整代码实现和详细注释
Vue中slot的使用(通俗易懂)
基于java+SpringBoot+Vue的宠物领养系统设计与实现
(精品)java宠物医院管理系统+论文+答辩ppt+部署视频+效果图效果视频
Java项目:312SSM宠物领养管理系统
tensorflow实现图像分类解决病虫害识别问题
原文链接: maven中使用scope= import https://www.mcbbbk.com/newsview1116315.html
| 上一篇: 妄想山海怎么捕捉 妄想山海抓宠物... | 下一篇: 《忘仙》宠物技能书应用指南:宠物... |





