SpringBoot是Spring技术栈的一个子工程,和我们熟知的Springframework同属于Spring的产品。
SpringBoot可以理解为我们搭建程序的脚手架,其主要的作用就是可以帮助我们快速的构建Spring项目,并且尽可能的减少一切xml配置,可以做到开箱即用,迅速上手,让我们可以更加专注业务而非配置。
springBoot的好处及特点
1、可以很快速的帮助我们快速整合(第三方框架),完全采用注解化的配置。
2、开箱即用(启动器starter-其实就是SpringBoot提供的一个jar包),但我们可以自己设置参数(.properties),即可快速摆脱这个方式。
3、springBoot提供了一些大型项目中常见的非功能性特性,如如安全、指标,健康检测、外部配置 内置Tomcat和Jetty容器
创建第一个SpringBoot项目
1、首先创建一个maven项目
2、创建完maven项目后在pom文件加入对应的依赖包
<!--添加父工程坐标 对各种常用依赖(并非全部)的版本进行了管理 可以理解为我们的之前的聚合的父pom-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
<dependencies>
<!--添加web启动器 SpringBoot提供的自动配置依赖 我们称为启动器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
3、配置完成后,我们需要去写一个启动类,去启动我们的springBoot
4、写一个controller就可以进行测试了
然后访问 http://localhost:8080/hello 就会出现
hello SpringBoot
就是这么简单。。。