一.SpringBoot概述
1.SpringBoot基本概念
简单理解,SpringBoot简化了Spring开发,简化了配置。SpringBoot是Spring的顶级项目之一。
2. Spring的缺点
·3.SpringBoot功能
4.SpringBoot的总结
二.SpringBoot快速入门
1.案例需求
2.代码编写,打开idea。
1)首先创建一个空项目springboot
2) 在空项目springboot中,新建一个maven模块项目,项目名称为springboot-helloworld。
3)用maven项目构建springboot项目;
- 打开pom.xml文件,加入以下内容:
<!--springboot工程需要继承的父工程-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
</parent>
如图所示:
2) 继续在pom.xml文件中,加入项目起步依赖:
<dependencies>
<!--web开发的起步依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
导入成功后,如图所示:
3)在src/main/java下新建一个一个包,包名自己起,我这里使用包名com.springboot。controller,接着,在这个包下,新建一个HelloController类;
5)在src/main/java下新建一个类,我这里类名取com.springboot.HelloApplication,包含包名。
6)启动项目,点击图中标红的1或者2好箭头所指的绿色箭头;
6)访问页面,打开浏览器,输入localhost:8080/hello即可。
http://localhost:8080/hello
三.SpringBoot项目总结