《Spring Boot实战》笔记(目录)

Posted WwjYt

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了《Spring Boot实战》笔记(目录)相关的知识,希望对你有一定的参考价值。

目录

目 录
第一部分 点睛Spring 4.x
第1 章 Spring 基础 ............................................................................................................. 2
1.1 Spring 概述 ................................................................................................................. 2
1.1.1 Spring 的简史 .................................................................................................. 2
1.1.2 Spring 概述 ...................................................................................................... 3
1.2 Spring 项目快速搭建 ................................................................................................. 5
1.2.1 Maven 简介 ...................................................................................................... 6
1.2.2 Maven 安装 ...................................................................................................... 6
1.2.3 Maven 的pom.xml ........................................................................................... 7
1.2.4 Spring 项目的搭建 .......................................................................................... 9
1.3 Spring 基础配置 ....................................................................................................... 17
1.3.1 依赖注入 ........................................................................................................ 18
1.3.2 Java 配置 ........................................................................................................ 21
1.3.3 AOP ................................................................................................................ 24
第2 章 Spring 常用配置 .................................................................................................... 30
2.1 Bean 的Scope ........................................................................................................... 30
2.1.1 点睛 ................................................................................................................ 30
2.1.2 示例 ................................................................................................................ 31
2.2 Spring EL 和资源调用.............................................................................................. 33
目 录 ∣ VII
2.2.1 点睛 ................................................................................................................ 33
2.2.2 示例 ................................................................................................................ 33
2.3 Bean 的初始化和销毁 .............................................................................................. 37
2.3.1 点睛 ................................................................................................................ 37
2.3.2 演示 ................................................................................................................ 38
2.4 Profile ........................................................................................................................ 40
2.4.1 点睛 ................................................................................................................ 40
2.4.2 演示 ................................................................................................................ 41
2.5 事件(Application Event) ...................................................................................... 44
2.5.1 点睛 ................................................................................................................ 44
2.5.2 示例 ................................................................................................................ 44
第3 章 Spring 高级话题 .................................................................................................... 48
3.1 Spring Aware ............................................................................................................. 48
3.1.1 点睛 ................................................................................................................ 48
3.1.2 示例 ................................................................................................................ 49
3.2 多线程 ....................................................................................................................... 51
3.2.1 点睛 ................................................................................................................ 51
3.2.2 示例 ................................................................................................................ 51
3.3 计划任务 ................................................................................................................... 54
3.3.1 点睛 ................................................................................................................ 54
3.3.2 示例 ................................................................................................................ 54
3.4 条件注解@Conditional ............................................................................................ 56
3.4.1 点睛 ................................................................................................................ 56
3.4.2 示例 ................................................................................................................ 57
3.5 组合注解与元注解 ................................................................................................... 60
3.5.1 点睛 ................................................................................................................ 60
3.5.2 示例 ................................................................................................................ 60
3.6 @Enable*注解的工作原理 ...................................................................................... 63
3.6.1 第一类:直接导入配置类 ............................................................................ 63
3.6.2 第二类:依据条件选择配置类 .................................................................... 64
3.6.3 第三类:动态注册Bean ............................................................................... 65
VIII ∣ Java EE 开发的颠覆者:Spring Boot 实战
3.7 测试 ........................................................................................................................... 66
3.7.1 点睛 ................................................................................................................ 66
3.7.2 示例 ................................................................................................................ 67
第二部分 点睛Spring MVC 4.x
第4 章 Spring MVC 基础 .................................................................................................. 72
4.1 Spring MVC 概述 ..................................................................................................... 73
4.2 Spring MVC 项目快速搭建 ..................................................................................... 74
4.2.1 点睛 ................................................................................................................ 74
4.2.2 示例 ................................................................................................................ 74
4.3 Spring MVC 的常用注解 ......................................................................................... 82
4.3.1 点睛 ................................................................................................................ 82
4.3.2 示例 ................................................................................................................ 83
4.4 Spring MVC 基本配置 ............................................................................................. 87
4.4.1 静态资源映射 ................................................................................................ 88
4.4.2 拦截器配置 .................................................................................................... 89
4.4.3 @ControllerAdvice ........................................................................................ 91
4.4.4 其他配置 ........................................................................................................ 94
4.5 Spring MVC 的高级配置 ......................................................................................... 98
4.5.1 文件上传配置 ................................................................................................ 98
4.5.2 自定义HttpMessageConverter .................................................................... 101
4.5.3 服务器端推送技术 ...................................................................................... 106
4.6 Spring MVC 的测试 ............................................................................................... 113
4.6.1 点睛 .............................................................................................................. 113
4.6.2 示例 .............................................................................................................. 114
第三部分 实战Spring Boot
第5 章 Spring Boot 基础 ................................................................................................. 122
5.1 Spring Boot 概述 ..................................................................................................... 122
5.1.1 什么是Spring Boot ...................................................................................... 122
目 录 ∣ IX
5.1.2 Spring Boot 核心功能 .................................................................................. 122
5.1.3 Spring Boot 的优缺点 .................................................................................. 124
5.1.4 关于本书的Spring Boot 版本 ..................................................................... 124
5.2 Spring Boot 快速搭建 ............................................................................................. 124
5.2.1 http://start.spring.io ....................................................................................... 124
5.2.2 Spring Tool Suite .......................................................................................... 127
5.2.3 IntelliJ IDEA ................................................................................................ 129
5.2.4 Spring Boot CLI ........................................................................................... 132
5.2.5 Maven 手工构建 .......................................................................................... 134
5.2.6 简单演示 ...................................................................................................... 136
第6 章 Spring Boot 核心 ................................................................................................. 138
6.1 基本配置 ................................................................................................................. 138
6.1.1 入口类和@SpringBootApplication ............................................................. 138
6.1.2 关闭特定的自动配置 .................................................................................. 139
6.1.3 定制Banner ................................................................................................. 139
6.1.4 Spring Boot 的配置文件 .............................................................................. 140
6.1.5 starter pom .................................................................................................... 141
6.1.6 使用xml 配置 .............................................................................................. 143
6.2 外部配置 ................................................................................................................. 143
6.2.1 命令行参数配置 .......................................................................................... 143
6.2.2 常规属性配置 .............................................................................................. 144
6.2.3 类型安全的配置(基于properties) ......................................................... 145
6.3 日志配置 ................................................................................................................. 148
6.4 Profile 配置 ............................................................................................................. 148
实战 .......................................................................................................................... 148
6.5 Spring Boot 运行原理 ............................................................................................. 150
6.5.1 运作原理 ...................................................................................................... 153
6.5.2 核心注解 ...................................................................................................... 154
6.5.3 实例分析 ...................................................................................................... 157
6.5.4 实战 .............................................................................................................. 160
X ∣ Java EE 开发的颠覆者:Spring Boot 实战
第7 章 Spring Boot 的Web 开发 .................................................................................... 170
7.1 Spring Boot 的Web 开发支持 ............................................................................... 170
7.2 Thymeleaf 模板引擎 ............................................................................................... 171
7.2.1 Thymeleaf 基础知识 .................................................................................... 171
7.2.2 与Spring MVC 集成 ................................................................................... 174
7.2.3 Spring Boot 的Thymeleaf 支持 ................................................................. 175
7.2.4 实战 .............................................................................................................. 177
7.3 Web 相关配置 ......................................................................................................... 182
7.3.1 Spring Boot 提供的自动配置 ...................................................................... 182
7.3.2 接管Spring Boot 的Web 配置 .................................................................... 185
7.3.3 注册Servlet、Filter、Listener .................................................................... 186
7.4 Tomcat 配置 ............................................................................................................ 187
7.4.1 配置Tomcat ................................................................................................. 187
7.4.2 代码配置Tomcat ......................................................................................... 188
7.4.3 替换Tomcat ................................................................................................. 190
7.4.4 SSL 配置 ...................................................................................................... 191
7.5 Favicon 配置 ........................................................................................................... 196
7.5.1 默认的Favicon ............................................................................................ 196
7.5.2 关闭Favicon ................................................................................................ 196
7.5.3 设置自己的Favicon .................................................................................... 197
7.6 WebSocket ............................................................................................................... 197
7.6.1 什么是WebSocket ....................................................................................... 197
7.6.2 Spring Boot 提供的自动配置 ...................................................................... 197
7.6.3 实战 .............................................................................................................. 198
7.7 基于Bootstrap 和AngularJS 的现代Web 应用 .................................................... 212
7.7.1 Bootstrap ...................................................................................................... 213
7.7.2 AngularJS ..................................................................................................... 216
7.7.3 实战 .............................................................................................................. 222
第8 章 Spring Boot 的数据访问 ...................................................................................... 233
8.1 引入Docker ............................................................................................................ 237
8.1.1 Docker 的安装 ............................................................................................. 238
目 录 ∣ XI
8.1.2 Docker 常用命令及参数 ............................................................................. 242
8.1.3 下载本书所需的Docker 镜像 .................................................................... 247
8.1.4 异常处理 ...................................................................................................... 247
8.2 Spring Data JPA ...................................................................................................... 248
8.2.1 点睛Spring Data JPA ................................................................................... 248
8.2.2 Spring Boot 的支持 ...................................................................................... 258
8.2.3 实战 .............................................................................................................. 260
8.3 Spring Data REST ................................................................................................... 284
8.3.1 点睛Spring Data REST ............................................................................... 284
8.3.2 Spring Boot 的支持 ...................................................................................... 285
8.3.3 实战 .............................................................................................................. 286
8.4 声名式事务 ............................................................................................................. 297
8.4.1 Spring 的事务机制 ...................................................................................... 297
8.4.2 声名式事务 .................................................................................................. 298
8.4.3 注解事务行为 .............................................................................................. 299
8.4.4 类级别使用@Transactional ......................................................................... 300
8.4.5 Spring Data JPA 的事务支持 ....................................................................... 300
8.4.6 Spring Boot 的事务支持 .............................................................................. 302
8.4.7 实战 .............................................................................................................. 303
8.5 数据缓存Cache ...................................................................................................... 309
8.5.1 Spring 缓存支持 .......................................................................................... 309
8.5.2 Spring Boot 的支持 ...................................................................................... 310
8.5.3 实战 .............................................................................................................. 312
8.5.4 切换缓存技术 .............................................................................................. 319
8.6 非关系型数据库NoSQL ........................................................................................ 320
8.6.1 MongoDB ..................................................................................................... 320
8.6.2 Redis ............................................................................................................. 329
第9 章 Spring Boot 企业级开发 ...................................................................................... 340
9.1 安全控制Spring Security ....................................................................................... 340
9.1.1 Spring Security 快速入门 ............................................................................ 340
9.1.2 Spring Boot 的支持 ...................................................................................... 347
XII ∣ Java EE 开发的颠覆者:Spring Boot 实战
9.1.3 实战 .............................................................................................................. 348
9.2 批处理Spring Batch ............................................................................................... 362
9.2.1 Spring Batch 快速入门 ................................................................................ 362
9.2.2 Spring Boot 的支持 ...................................................................................... 370
9.2.3 实战 .............................................................................................................. 371
9.3 异步消息 ................................................................................................................. 385
9.3.1 企业级消息代理 .......................................................................................... 386
9.3.2 Spring 的支持 .............................................................................................. 386
9.3.3 Spring Boot 的支持 ...................................................................................... 386
9.3.4 JMS 实战 ...................................................................................................... 387
9.3.5 AMQP 实战 ................................................................................................. 391
9.4 系统集成Spring Integration ................................................................................... 395
9.4.1 Spring Integration 快速入门 ........................................................................ 395
9.4.2 Message ........................................................................................................ 395
9.4.3 Channel ......................................................................................................... 395
9.4.4 Message EndPoint ........................................................................................ 398
9.4.5 Spring Integration Java DSL ........................................................................ 400
9.4.6 实战 .............................................................................................................. 400
第10 章 Spring Boot 开发部署与测试 ............................................................................. 407
10.1 开发的热部署 ....................................................................................................... 407
10.1.1 模板热部署 ................................................................................................ 407
10.1.2 Spring Loaded ............................................................................................ 407
10.1.3 JRebel ......................................................................................................... 409
10.1.4 spring-boot-devtools ................................................................................... 413
10.2 常规部署 ............................................................................................................... 413
10.2.1 jar 形式 ....................................................................................................... 413
10.2.2 war 形式 ..................................................................................................... 417
10.3 云部署——基于Docker 的部署 ......................................................................... 419
10.3.1 Dockerfile ................................................................................................... 419
10.3.2 安装Docker ............................................................................................... 421
10.3.3 项目目录及文件 ........................................................................................ 421
目 录 ∣ XIII
10.3.4 编译镜像 .................................................................................................... 423
10.3.5 运行 ............................................................................................................ 424
10.4 Spring Boot 的测试 ............................................................................................... 424
10.4.1 新建Spring Boot 项目 ............................................................................... 425
10.4.2 业务代码 .................................................................................................... 425
10.4.3 测试用例 .................................................................................................... 427
10.4.4 执行测试 .................................................................................................... 429
第11 章 应用监控 ........................................................................................................... 431
11.1 http ......................................................................................................................... 431
11.1.1 新建Spring Boot 项目 ............................................................................... 432
11.1.2 测试端点 .................................................................................................... 432
11.1.3 定制端点 .................................................................................................... 439
11.1.4 自定义端点 ................................................................................................ 440
11.1.5 自定义HealthIndicator .............................................................................. 444
11.2 JMX ....................................................................................................................... 447
11.3 SSH ........................................................................................................................ 449
11.3.1 新建Spring Boot 项目 ............................................................................... 449
11.3.2 运行 ............................................................................................................ 449
11.3.3 常用命令 .................................................................................................... 451
11.3.4 定制登录用户 ............................................................................................ 452
11.3.5 扩展命令 .................................................................................................... 452
第12 章 分布式系统开发 ................................................................................................ 456
12.1 微服务、原生云应用 ........................................................................................... 456
12.2 Spring Cloud 快速入门 ......................................................................................... 457
12.2.1 配置服务 .................................................................................................... 457
12.2.2 服务发现 .................................................................................................... 457
12.2.3 路由网关 .................................................................................................... 457
12.2.4 负载均衡 .................................................................................................... 457
12.2.5 断路器 ........................................................................................................ 458
XIV ∣ Java EE 开发的颠覆者:Spring Boot 实战
12.3 实战 ....................................................................................................................... 458
12.3.1 项目构建 .................................................................................................... 458
12.3.2 服务发现——Discovery(Eureka Server) ............................................. 459
12.3.3 配置——Config(Config Server) ........................................................... 461
12.3.4 服务模块——Person 服务 ........................................................................ 463
12.3.5 服务模块——Some 服务 .......................................................................... 466
12.3.6 界面模块——UI(Ribbon,Feign) .......................................................... 468
12.3.7 断路器监控——Monitor(DashBoard) ................................................. 473
12.3.8 运行 ............................................................................................................ 474
12.4 基于Docker 部署 ................................................................................................. 478
12.4.1 Dockerfile 编写 .......................................................................................... 478
12.4.2 Docker Compose ........................................................................................ 480
12.4.3 Docker-compose.yml 编写 ......................................................................... 481
12.4.4 运行 ............................................................................................................ 483
附录A ............................................................................................................................... 485
A.1 基于JHipster 的代码生成 ..................................................................................... 485
A.2 常用应用属性配置列表 ........................................................................................ 488

以上是关于《Spring Boot实战》笔记(目录)的主要内容,如果未能解决你的问题,请参考以下文章

Vue + Spring Boot 项目实战笔记

Spring Boot实战笔记-- Spring高级话题(计划任务)

Spring Boot实战笔记-- Spring高级话题(Spring Aware)

Spring Boot 入门与实战笔记

Spring Boot 入门与实战笔记

JavaEE开发的颠覆者 Spring Boot实战--笔记