springboot的pom文件依赖

Spring_Boot专栏
上一篇主目录 下一篇

【前言】
pom是maven用来管理项目的项目对象模型,springboot项目的依赖如何配置?


springboot基本依赖

在使用spring initializer去创建spring项目(链接)时,默认生成的pom文件中的依赖有:

parent

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
  • 【注】spring-boot-starter是一个场景启动器。springboot将所有的功能场景抽取出来,做成一个个的启动器starter,只需要在项目里引入这些starter,相关场景的所有依赖都会导入进来,要用什么功能就导入什么启动器

这个parent为我们管理依赖的版本,是springboot的版本仲裁中心,以后我们导入的依赖中不需要写版本。parent管理的依赖的版本包括(不在管理范围内的才需要手动指定版本):
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

starter-web

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

spring-boot-starter-web是一个场景启动器,启动的是springboot的web场景,同上Ctrl+鼠标左键,可以看到启动web场景需要的依赖有:spring-boot-starter、spring-boot-starter-json、spring-boot-starter-tomcat等。

starter-test

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

测试场景的启动器

maven-plugin

maven的插件,配置插件的依赖以后可以进行打jar包等操作

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值