【Spring Boot (一)】Spring Boot 基础入门

Spring 的能做什么

Spring 的能力。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-tPShWhiF-1628676376971)(https://simplestark.top/upload/2021/08/image-458c332bd4f1420ab2cf5536626c1c13.png)]

以上是Spring 官网的截图,从左到右分别对应着微服务开发、响应式编程、分布式云开发(Spring Cloud)、Web 开发、无服务开发、事件驱动开发、批处理业务,在这里Spring 指的就不仅仅是Spring 框架了,而是指的Spring 的生态圈,通过Spring 的生态圈,我们可以做到以上我们想做的。

为什么用Spring Boot?

以上的东西都是基于Spring 的生态来的,而Spring Boot就是为了整合这个生态诞生的。

Spring Boot makes it easy to create stand-alone, production-grade Spring-based Applications that you can run. We take an opinionated view of the Spring platform and third-party libraries, so that you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.

上面的英文就是Spring 官网关于Spring Boot 的介绍,翻译过来就是:“Spring Boot使得创建可以运行的独立的、基于Spring的生产级应用程序变得很容易。我们对Spring 平台和第三方库持固执己见的观点,所以您可以从最简单的开始。大多数Spring Boot应用程序只需要很少的Spring配置。”
对于Spring Boot能够很容易的创建一个可以独立运行的应用大家应该都能够理解,但是其中的“我们对Spring 平台和第三方库持固执己见的观点”这就话是什么意思呢,这句话的意思就是我们平时常说的:约定大于配置。

而又要怎么理解约定大于配置呢?在我看来,在传统基于Spring的Java Web应用种,需要配置web.xml, applicationContext.xml,将应用打成war包放入应用服务器(Tomcat, Jetty等)中并运行。而Spring Boot就不需要我们配置这些,他内嵌了Tomcat服务器,只需要引入相关的依赖就可以了。这就是Spring Boot 的约定大于配置:在传统所需要配置的地方,SpringBoot都进行了约定(配置好了),开发人员能配置得更少,更直接地开发项目,写业务逻辑代码。

Spring Boot 的优点

  • Create stand-alone Spring applications
    • 创建独立Spring应用
  • Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
    • 内嵌web服务器
  • Provide opinionated ‘starter’ dependencies to simplify your build configuration
    • 自动starter依赖,简化构建配置
  • Automatically configure Spring and 3rd party libraries whenever possible
    • 自动配置Spring以及第三方功能
  • Provide production-ready features such as metrics, health checks, and externalized configuration
    • 提供生产级别的监控、健康检查及外部化配置
  • Absolutely no code generation and no requirement for XML configuration
    • 无代码生成、无需编写XML

可以说Spring Boot 是Spring 框架的框架,它整合了Spring 的全部技术栈。是简化Spring 技术栈的快速开发脚手架。

Spring 的缺点

  • 版本迭代快,需要时刻关注变化
  • 封装太深,内部原理复杂,不容易精通

Spring Boot 所处的大时代背景

简单介绍一下Spring 生态在当前的时代背景能够做些什么。

微服务

James Lewis and Martin Fowler (2014) 提出微服务完整概念。https://martinfowler.com/microservices/

In short, the microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies.-- James Lewis and Martin Fowler (2014)

上面的介绍翻译成中文就是:“简而言之,微服务体系结构风格是一种将单个应用程序开发为一组小服务的方法,每个小服务都在自己的进程中运行,并使用轻量级机制(通常是HTTP资源API)进行通信。这些服务是围绕业务功能构建的,可以通过完全自动化的部署机制独立部署。这些服务的集中管理是最低限度的,可以用不同的编程语言编写,并使用不同的数据存储技术。”

可以总结为以下几点:

  • 微服务是一种架构风格
  • 一个应用拆分为一组小型服务
  • 每个服务运行在自己的进程内,也就是可独立部署和升级
  • 服务之间使用轻量级HTTP交互
  • 服务围绕业务功能拆分
  • 可以由全自动部署机制独立部署
  • 去中心化,服务自治。服务可以使用不同的语言、不同的存储技术

分布式

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-iIpc6aYE-1628676376977)(https://simplestark.top/upload/2021/08/image-62f87733e3614d74adf1401fe76aa1bb.png)]

由于微服务的出现,引出了我们分布式的概念,并遇到许多新的问题,比如:

  • 远程调用
  • 服务发现
  • 负载均衡
  • 服务容错
  • 配置管理
  • 服务监控
  • 链路追踪
  • 日志管理
  • 任务调度

分布式解决方案

SpringBoot + SpringCloud

在这里插入图片描述

云原生

原生应用如何上云。 Cloud Native

云原生的困难

  • 服务自愈
  • 弹性伸缩
  • 服务隔离
  • 自动化部署
  • 灰度发布
  • 流量治理

云原生的解决方案

cloud Native

如何学习SpringBoot

Spring 官网文档架构

在这里插入图片描述

查看版本新特性:https://github.com/spring-projects/spring-boot/wiki#release-notes
在这里插入图片描述

写在最后

这篇博客基于B站尚硅谷的视频:雷丰阳2021版SpringBoot2零基础入门springboot全套完整版(spring boot2)编写。
在此先表示感谢。
如有侵权,请联系我删除。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值