SpringBoot 从入门到光头 第一章 Spring 与 SpringBoot


SpringBoot 从入门到光头 —— 第一章 Spring 与 SpringBoot


1. Spring 能做什么

1.1. Spring 的能力

SpringCanDo

1.2. Spring 的生态

SpringProjects

覆盖了:

  • Web 开发
  • 数据访问
  • 安全控制
  • 分布式
  • 消息服务
  • 移动开发
  • 批处理

1.3. Spring5 的重大升级

1.3.1. 响应式编程

SpringReactor

1.3.2. 内部源码设计

基于 Java8 的一些新特性,如:接口默认实现,重新设计了源码架构。

2. 为什么用 SpringBoot

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”.

能快速创建出生产级别的 Spring 应用

2.1. SpringBoot 的优点

  • 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

SpringBoot 是整合 Spring 技术栈的一站式框架

SpringBoot 是简化 Spring 技术栈的快速开发脚手架

2.2. SpringBoot 的缺点

  • 人称版本帝,迭代快,需要时时关注变化
  • 封装太深,内部远离复杂,不容易精通

3. 时代背景

3.1. 微服务

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 交互
  • 服务围绕业务功能拆分
  • 可以由全自动部署机制独立部署
  • 去中心化,服务自治。服务可以使用不同的语言、不同的存储技术

3.2. 分布式

分布式的困难
  • 远程调用
  • 服务发现
  • 负载均衡
  • 服务容错
  • 配置管理
  • 服务监控
  • 链路追踪
  • 日志管理
  • 任务调度
  • ……
分布式的解决

SpringBoot + SpringCloud

SpringBootAndSpringCloud

3.3. 云原生

原生应用如何上云:Cloud Native

上云的困难
  • 服务自愈
  • 弹性伸缩
  • 服务隔离
  • 自动化部署
  • 灰度发布
  • 流量治理
  • ……

4. 如何学习 SpringBoot

4.1. 官网文档架构

Spring Boot Reference Documentation

https://docs.spring.io/spring-boot/docs/2.5.6/reference/html/

SpringBootDocumentation

链接 内容
Legal 基本法律信息
Getting Help 获取帮助资源
Documentation Overview 关于文档,以及前导步骤等。
Getting Started 介绍 Spring Boot、System Requirements、Servlet 容器、安装 Spring Boot、开发第一个 Spring Boot 应用程序
Upgrading Spring Boot Applications 从1.x升级,升级到新功能版本,升级 Spring Boot CLI
Using Spring Boot 构建系统、构建代码、配置、Spring Beans 和依赖注入、DevTools 等
Spring Boot Features 配置文件、日志记录、安全性、缓存、弹性集成、测试等
Spring Boot Actuator 生成、指标、监控等
Deploying Spring Boot Applications 部署到云端,作为 Unix 应用程序安装
Spring Boot CLI 安装 CLI、使用 CLI、配置 CLI 等
Build Tool Plugins Maven 插件、Gradle 插件、Antlib 等
“How-to” Guides 应用程序开发、配置、嵌入式服务器、数据访问等技巧

查看版本新特性:

https://github.com/spring-projects/spring-boot/wiki#release-notes

SpringReleases



文章作者: gregPerlinLi
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 gregPerlinLi !
  目录