一、方式一:spring-boot-starter-parent

  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

【Spring Boot】Spring Boot之两种引入spring boot maven依赖的方式

 进入spring-boot-starter-parent里,可以发现它其实依赖了我们下面要讲的spring-boot-dependencies模块 。

二、方式二:使用spring-boot-dependencies

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>2.2.1.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

使用这种方式就不用继承父模块,可以解决单继承的问题。这样就可以继承其他父模块,比如自己创建的父模块。
scope=import,type=pom表示在此pom中引入spring-boot-dependencies的pom的所有内容,注意只能在dependencyManagement中使用。
大多数我们可能用到的包依赖和插件依赖都已经在spring-boot-dependencies中定义好了

【Spring Boot】Spring Boot之两种引入spring boot maven依赖的方式

 

相关文章:

  • 2022-12-23
  • 2021-10-31
  • 2021-09-05
  • 2021-11-06
  • 2021-11-08
  • 2021-11-02
  • 2022-01-01
  • 2022-12-23
猜你喜欢
  • 2018-03-13
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
  • 2019-09-02
  • 2022-12-23
相关资源
相似解决方案