一、Spring Boot简介:
SpringBoot基于Spring4.0设计,不仅继承了Spring框架原有的优秀特性,而且还通过简化配置来进一步简化了Spring应用的整个搭建和开发过程。另外SpringBoot通过集成大量的框架使得依赖包的版本冲突,以及引用的不稳定性等问题得到了很好的解决。
优点:
①独立创建Spring应用
②不需要写大量样板化的配置文件
③内嵌web服务器
④自动Starter依赖
⑤自动配置Spring
SpringBoot是整合Spring技术栈的一站式框架
SpringBoot是简化Spring技术栈的快速开发脚手架
缺点:
①迭代快
②封装太深 内部原理复杂 不容易精通
二、第一个Spring Boot程序
Hello World
pom.xml:
<groupId>org.example</groupId> <artifactId>com.springboot</artifactId> <version>1.0-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.4.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
一、创建一个java类,写上@SpringBootApplication注解,并在main方法里写上启动run方法
二、创建Controller层
三、运行Hello world
启动的时候控制台打印的内容
默认端口是8080
访问localhost:8080/hello 第一个Spring Boot程序“hello world”就写好啦