Fur*_*vuz 5 java spring module maven spring-boot
我正在向项目添加新的 maven 模块。它将使用 spring-boot。旧模块不使用它。所以,我的新模块必须是父项目的子项,但同时必须是 spring-boot-starter-parent 的子项。我怎样才能让我的项目成为 2 个不同父母的孩子?
我现在的父母
<parent>
<groupId>com.somegroup</groupId>
<artifactId>Parent</artifactId>
<version>1.0</version>
</parent>
Run Code Online (Sandbox Code Playgroud)
Spring-boot 父级
<parent>
<!-- Your own application should inherit from spring-boot-starter-parent -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>
Run Code Online (Sandbox Code Playgroud)
由于 Maven 项目只能有一个父项目,因此您可以使用不同的方法。您可以在依赖项管理部分中导入spring-boot-dependencies并保留原始父级,而不是继承。
<parent>
<groupId>com.somegroup</groupId>
<artifactId>Parent</artifactId>
<version>1.0</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)
您可以阅读官方文档中的约束,这些约束基本上是关于更改 Spring Boot 提供的依赖项版本的方式。
| 归档时间: |
|
| 查看次数: |
2521 次 |
| 最近记录: |