SpringBoot之优势及应⽤场景
⼀、优势
1、简化编码
假如要创建⼀个web应⽤,在使⽤spring的时候,都需要在pom⽂件中添加多个依赖,⽽springboot则帮助我们启动⼀个web容器,在springboot中我们只需要在pom⽂件中添加⼀个starter-web依赖即可。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
点开看看,springboot的starter-web包含了多个依赖,包括之前在spring⼯程中导⼊的依赖,其中⼀部分依赖如下:
<!-- .....省略其他依赖 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.8.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
spring mvc和boot区别<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.1.8.RELEASE</version>
<scope>compile</scope>
</dependency>
由此可见,springboot⼤⼤简化了我们的编码,之前导⼊多个依赖,现在只需导⼊⼀个依赖即可。
2、简化部署
在使⽤springmvc时,项⽬部署时我们需要在服务器上部署tomact或其他web应⽤服务器,然后把项⽬打成war包放到web容器中去。使⽤springboot后,我们不再需要在服务器上部署tomact,因为springboot内嵌了tomact服务器,只需要将项⽬打成jar包,使⽤java -jar xxx.jar ⼀键式启动项⽬。同时也降低对运⾏环境的⽽基本要求,环境变量中有jdk即可。
3、简化配置
4、简化监控
⼆、应⽤场景
(⼀)、@EnableAsync和@Async的作⽤和基本⽤法
异步执⾏

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。