微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

spring-boot-dependencies 和 spring-boot-starter-parent

copy自:spring-boot-dependencies 和 spring-boot-starter-parent

构建springboot项目有两种方式:

第一种是继承spring-boot-starter-parent

pom里面指定parent项目:

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

[推荐,常用]第二种是通过dependencyManagement进行依赖管理

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

共同点

这两种方式,我们在使用spring-boot-starter的时候都不需要指定版本;

 

  继承spring-boot-starter-parent其实也算是继承自spring-boot-dependencies,我们点开spring-boot-starter-parent,可以看到parent其实也是继承dependencies,parent里面就增加了一些插件,然后指定了maven编译版本:

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐