第一章Spring
Spring生态有Springboot、SpringData、SpringCloud、SpringBatch、SpirngFramework、SpringSecurity…。
通常我们说的是SpringFramework和Springboot的区别
Spirng生态能做什么
1.Microserivices(微服务)
2.Reactive
3.Cloud
4.Web app
5.Servless(无服务)
6.Eventdriver
7.Batch
Springboot是什么
Springboot底层是Springframework,基于Springframework的加强版。以往Springframework需要写非常多的配置文件,Springboot出现的初衷就是解决写配置文件的繁琐操作。
总结Springboot的优缺点
优点
1.能创建独立的spring应用,替代spring
2.内部嵌入web服务器(应用打包好内置web服务器,这样服务器都不需要安装相应服务就能够运行)
3.自动的Starter依赖,里面已经写好依赖了,只需要根据相应的环境,提取出特定的依赖。
4.自动配置Spring以及第三方功能
5.提供生产级别的监控,健康检查及外部化配置(自带监控,通过特定的方法修改源代码,不需要进入源代码修改)
6.无代码生成,无需编写xml
缺点
1.版本迭代快
2.底层太深,内部原理复杂
微服务
- 微服务是一种架构风格
- 一个应用拆分成一组小型服务
- 每个服务运行在自己的进程内,也就是可独立部署和升级
- 服务之间使用轻量级HTTP交互
- 服务围绕业务功能拆分
- 可以全自动部署机制
- 去中心化,服务自治。服务可以使用各不同的语言,不同存储技术
微服务产生的分布式
分布式的困难
1. 远程调用
2. 服务发现
3. 负载均衡
4. 服务容错
5. 配置管理
6. 链路追踪
7. 日志管理
8. 任务调度
Springboot对于分布式问题的解决方案
Springboot-Springcloud-Springdataflow
第二章进入Springboot
里面的操作在官方手册里都有了,学习路线也是按照官方操作手册学
网址spring.io
配置maven
修改xml文件
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<!-- 添加仓库地址 -->
<localRepository>D:\apache-maven-3.6.3-bin\apache-maven-3.6.3\repository</localRepository>
<!-- 添加阿里云的镜像,这样下载依赖的时候就比较快 -->
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
-->
<!-- 添加默认的jdk -->
<properties>
<tomcatPath>/path/to/tomcat/instance</tomcatPath>
</properties>
</profile>
-->
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
添加场景启动器
在maven的xml文件里面写上
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
</parent>
添加web的环境依赖(这样maven就自动添加了web环境需要的基本依赖,不需要在去导包了)
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>