-
Notifications
You must be signed in to change notification settings - Fork 421
Expand file tree
/
Copy pathindex.html
More file actions
397 lines (242 loc) · 61.4 KB
/
index.html
File metadata and controls
397 lines (242 loc) · 61.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>部分 IV. Spring Boot</title><link rel="stylesheet" type="text/css" href="../docbook.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="home" href="../index.html" title="Netkiller Java 手札(版)" /><link rel="up" href="../index.html" title="Netkiller Java 手札(版)" /><link rel="prev" href="../build/jitpack.html" title="第 25 章 JitPack - Easy to use package repository for Git" /><link rel="next" href="spring.boot.quickstart.html" title="第 26 章 Spring Boot Quick start" /></head><body><a xmlns="" href="//www.netkiller.cn/">Home</a> | <a xmlns="" href="//netkiller.github.io/">简体中文</a> | <a xmlns="" href="http://netkiller.sourceforge.net/">繁体中文</a> | <a xmlns="" href="/journal/index.html">杂文</a>
| <a xmlns="" href="https://github.com/netkiller">Github</a> | <a xmlns="" href="https://zhuanlan.zhihu.com/netkiller">知乎专栏</a> | <a xmlns="" href="https://www.facebook.com/bg7nyt">Facebook</a> | <a xmlns="" href="http://cn.linkedin.com/in/netkiller/">Linkedin</a> | <a xmlns="" href="https://www.youtube.com/user/bg7nyt/videos">Youtube</a> | <a xmlns="" href="//www.netkiller.cn/home/donations.html">打赏(Donations)</a> | <a xmlns="" href="//www.netkiller.cn/home/about.html">About</a><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">部分 IV. Spring Boot</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="../build/jitpack.html">上一页</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="spring.boot.quickstart.html">下一页</a></td></tr></table><hr /></div><table xmlns=""><tr><td><iframe src="//ghbtns.com/github-btn.html?user=netkiller&repo=netkiller.github.io&type=watch&count=true&size=large" height="30" width="170" frameborder="0" scrolling="0" style="width:170px; height: 30px;" allowTransparency="true"></iframe></td><td><iframe src="//ghbtns.com/github-btn.html?user=netkiller&repo=netkiller.github.io&type=fork&count=true&size=large" height="30" width="170" frameborder="0" scrolling="0" style="width:170px; height: 30px;" allowTransparency="true"></iframe></td><td><iframe src="//ghbtns.com/github-btn.html?user=netkiller&type=follow&count=true&size=large" height="30" width="240" frameborder="0" scrolling="0" style="width:240px; height: 30px;" allowTransparency="true"></iframe></td><td></td><td><a href="https://zhuanlan.zhihu.com/netkiller"><img src="/images/logo/zhihu-card-default.svg" height="25" /></a></td><td valign="middle"><a href="https://zhuanlan.zhihu.com/netkiller">知乎专栏</a></td><td></td><td></td><td></td><td></td></tr></table><div class="part"><div class="titlepage"><div><div><h1 class="title"><a id="index"></a>部分 IV. Spring Boot</h1></div></div></div><div class="toc"><p><strong>目录</strong></p><dl class="toc"><dt><span class="chapter"><a href="spring.boot.quickstart.html">26. Spring Boot Quick start</a></span></dt><dd><dl><dt><span class="section"><a href="spring.boot.quickstart.html#id1008">26.1. 创建项目</a></span></dt><dt><span class="section"><a href="pom.html">26.2. pom.xml</a></span></dt><dt><span class="section"><a href="controller.html">26.3. Controller</a></span></dt><dt><span class="section"><a href="spring-boot-maven-plugin.html">26.4. Springboot with Maven</a></span></dt><dd><dl><dt><span class="section"><a href="spring-boot-maven-plugin.html#id1009">26.4.1. resource</a></span></dt><dt><span class="section"><a href="spring-boot-maven-plugin.html#id1010">26.4.2. Maven run</a></span></dt><dt><span class="section"><a href="spring-boot-maven-plugin.html#id1011">26.4.3. Spring Boot maven 插件 build-image</a></span></dt><dt><span class="section"><a href="spring-boot-maven-plugin.html#id1012">26.4.4. 生成项目信息</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="suite.html">27. Spring 开发环境</a></span></dt><dd><dl><dt><span class="section"><a href="suite.html#id1013">27.1. Java 开发环境</a></span></dt><dt><span class="section"><a href="install.html">27.2. 安装 Spring Tool Suite</a></span></dt><dt><span class="section"><a href="dashboard.html">27.3. Dashboard</a></span></dt><dt><span class="section"><a href="start.spring.io.html">27.4. Spring Initializr - Bootstrap your application</a></span></dt></dl></dd><dt><span class="chapter"><a href="SpringApplication.html">28. SpringApplication</a></span></dt><dd><dl><dt><span class="section"><a href="SpringApplication.html#spring.run">28.1. 运行 Spring boot 项目</a></span></dt><dd><dl><dt><span class="section"><a href="SpringApplication.html#id1014">28.1.1. Linux systemd</a></span></dt><dt><span class="section"><a href="SpringApplication.html#id1015">28.1.2. 传统 init.d 脚本</a></span></dt><dt><span class="section"><a href="SpringApplication.html#war">28.1.3. 编译用于Tomcat的 War</a></span></dt></dl></dd><dt><span class="section"><a href="SpringBootApplication.html">28.2. @SpringBootApplication</a></span></dt><dd><dl><dt><span class="section"><a href="SpringBootApplication.html#id1016">28.2.1. 排除 @EnableAutoConfiguration 加载项</a></span></dt></dl></dd><dt><span class="section"><a href="获取Resources中的文件.html">28.3. 获取 Resources 目录中的静态文件</a></span></dt><dt><span class="section"><a href="EnableAutoConfiguration.html">28.4. @EnableAutoConfiguration</a></span></dt><dt><span class="section"><a href="@ComponentScan.html">28.5. @ComponentScan</a></span></dt><dt><span class="section"><a href="@EntityScan.html">28.6. @EntityScan 实体扫描</a></span></dt><dt><span class="section"><a href="@EnableJpaRepositories.html">28.7. @EnableJpaRepositories</a></span></dt><dt><span class="section"><a href="启动和销毁.html">28.8. 启动和销毁</a></span></dt><dt><span class="section"><a href="打印环境变量.html">28.9. 打印环境变量</a></span></dt><dt><span class="section"><a href="CharacterEncodingFilter.html">28.10. CharacterEncodingFilter</a></span></dt><dt><span class="section"><a href="banner.html">28.11. 隐藏 Banner</a></span></dt><dt><span class="section"><a href="scan.html">28.12. 实体与仓库扫描</a></span></dt><dt><span class="section"><a href="beans.html">28.13. 列出 Beans</a></span></dt><dt><span class="section"><a href="spring.boot.ports.html">28.14. Tomcat 端口</a></span></dt><dt><span class="section"><a href="启动配置项.html">28.15. 配置项设定</a></span></dt><dt><span class="section"><a href="spring.profiles.active.html">28.16. spring.profiles.active</a></span></dt><dt><span class="section"><a href="@Profile.html">28.17. @Profile("dev") / @ActiveProfiles("dev")</a></span></dt><dt><span class="section"><a href="spring.boot.timezone.html">28.18. 设置默认时区</a></span></dt></dl></dd><dt><span class="chapter"><a href="spring.boot.shutdown.html">29. 如何优雅停止 Springboot 运行</a></span></dt><dd><dl><dt><span class="section"><a href="spring.boot.shutdown.html#id1017">29.1. 准备工作</a></span></dt><dt><span class="section"><a href="ch29s02.html">29.2. kill 命令演示</a></span></dt><dt><span class="section"><a href="ch29s03.html">29.3. 容器中如何优雅关闭 Springboot</a></span></dt><dt><span class="section"><a href="ch29s04.html">29.4. 写入PID文件</a></span></dt></dl></dd><dt><span class="chapter"><a href="properties/index.html">30. Properties 配置文件</a></span></dt><dd><dl><dt><span class="section"><a href="properties/index.html#application.properties">30.1. application.properties 配置文件</a></span></dt><dd><dl><dt><span class="section"><a href="properties/index.html#faq.application.properties">30.1.1. application.properties 参考</a></span></dt><dt><span class="section"><a href="properties/index.html#spring.config.location">30.1.2. 启动指定参数</a></span></dt><dt><span class="section"><a href="properties/index.html#spring.autoconfigure.exclude">30.1.3. 加载排除</a></span></dt><dt><span class="section"><a href="properties/index.html#spring.pid">30.1.4. PID FILE</a></span></dt><dt><span class="section"><a href="properties/index.html#spring.main.banner-mode">30.1.5. banner 关闭</a></span></dt><dt><span class="section"><a href="properties/index.html#server">30.1.6. server</a></span></dt><dt><span class="section"><a href="properties/index.html#logging">30.1.7. logging</a></span></dt><dt><span class="section"><a href="properties/index.html#server.tomcat">30.1.8. 内嵌 tomcat server</a></span></dt><dt><span class="section"><a href="properties/index.html#spring.servlet">30.1.9. servlet</a></span></dt><dt><span class="section"><a href="properties/index.html#spring.jackson">30.1.10. JSON 输出与日期格式化</a></span></dt><dt><span class="section"><a href="properties/index.html#mail">30.1.11. SMTP 相关配置</a></span></dt><dt><span class="section"><a href="properties/index.html#redis">30.1.12. Redis</a></span></dt><dt><span class="section"><a href="properties/index.html#mongodb">30.1.13. MongoDB</a></span></dt><dt><span class="section"><a href="properties/index.html#mysql">30.1.14. MySQL</a></span></dt><dt><span class="section"><a href="properties/index.html#oracle">30.1.15. Oracle</a></span></dt><dt><span class="section"><a href="properties/index.html#default_schema">30.1.16. default_schema</a></span></dt><dt><span class="section"><a href="properties/index.html#datasource">30.1.17. datasource</a></span></dt><dt><span class="section"><a href="properties/index.html#velocity">30.1.18. velocity</a></span></dt><dt><span class="section"><a href="properties/index.html#security">30.1.19. Security 相关配置</a></span></dt><dt><span class="section"><a href="properties/index.html#mvc">30.1.20. MVC 配置</a></span></dt><dt><span class="section"><a href="properties/index.html#kafka">30.1.21. Kafka 相关配置</a></span></dt></dl></dd><dt><span class="section"><a href="properties/properties.html">30.2. Properties 文件</a></span></dt><dd><dl><dt><span class="section"><a href="properties/properties.html#@Value">30.2.1. @Value 注解</a></span></dt><dt><span class="section"><a href="properties/properties.html#ConfigurationProperties">30.2.2. @EnableConfigurationProperties 引用自定义 *.properties 配置文件</a></span></dt><dt><span class="section"><a href="properties/properties.html#@PropertySource">30.2.3. @PropertySource 注解载入 properties 文件</a></span></dt></dl></dd><dt><span class="section"><a href="properties/Environment.html">30.3. Environment 读取配置文件</a></span></dt><dt><span class="section"><a href="properties/ch30s04.html">30.4. 手工载入 *.properties 文件</a></span></dt><dd><dl><dt><span class="section"><a href="properties/ch30s04.html#id1021">30.4.1. 家在 resources 目录中的指定文件</a></span></dt><dt><span class="section"><a href="properties/ch30s04.html#id1022">30.4.2. 从 InputStreamReader 打开 application.properties</a></span></dt></dl></dd><dt><span class="section"><a href="properties/ch30s05.html">30.5. 命令行注入配置项</a></span></dt><dd><dl><dt><span class="section"><a href="properties/ch30s05.html#spring.profiles.active">30.5.1. spring.profiles.active 参数切换配置文件</a></span></dt><dt><span class="section"><a href="properties/ch30s05.html#id1023">30.5.2. SpringApplicationBuilder.properties() 方法添加配置项</a></span></dt><dt><span class="section"><a href="properties/ch30s05.html#setAddCommandLineProperties">30.5.3. 禁用命令行注入环境变量</a></span></dt></dl></dd><dt><span class="section"><a href="properties/PropertyResolver.html">30.6. PropertyResolver 获取配置</a></span></dt><dt><span class="section"><a href="properties/ch30s07.html">30.7. 参数引用</a></span></dt><dt><span class="section"><a href="properties/ch30s08.html">30.8. 默认值</a></span></dt><dt><span class="section"><a href="properties/ch30s09.html">30.9. 产生随机数</a></span></dt><dd><dl><dt><span class="section"><a href="properties/ch30s09.html#id1024">30.9.1. 随机数</a></span></dt></dl></dd><dt><span class="section"><a href="properties/ch30s10.html">30.10. 多行字符串</a></span></dt><dt><span class="section"><a href="properties/ch30s11.html">30.11. 注入多值属性 arrays, list, set</a></span></dt><dt><span class="section"><a href="properties/ch30s12.html">30.12. List 列表类型</a></span></dt><dt><span class="section"><a href="properties/ch30s13.html">30.13. Map类型</a></span></dt><dt><span class="section"><a href="properties/ch30s14.html">30.14. Binder</a></span></dt><dt><span class="section"><a href="properties/jasypt-spring-boot-starter.html">30.15. 加密 application.properties 中的敏感内容</a></span></dt></dl></dd><dt><span class="chapter"><a href="spring.boot.logging.html">31. Spring boot with Logging</a></span></dt><dd><dl><dt><span class="section"><a href="spring.boot.logging.html#application.properties.logging">31.1. 配置日志文件</a></span></dt><dd><dl><dt><span class="section"><a href="spring.boot.logging.html#id1025">31.1.1. 日志输出级别</a></span></dt><dt><span class="section"><a href="spring.boot.logging.html#id1026">31.1.2. Spring boot 2.1 以后的版本不打印 Mapped 日志问题</a></span></dt><dt><span class="section"><a href="spring.boot.logging.html#id1027">31.1.3. 禁止控制台输出日志</a></span></dt><dt><span class="section"><a href="spring.boot.logging.html#id1028">31.1.4. 定制日志格式</a></span></dt><dt><span class="section"><a href="spring.boot.logging.html#id1029">31.1.5. 彩色输出</a></span></dt></dl></dd><dt><span class="section"><a href="logging.logback.html">31.2. 日志切割</a></span></dt><dt><span class="section"><a href="logging.ansi.html">31.3. 彩色日志</a></span></dt><dt><span class="section"><a href="lombok.logging.html">31.4. 打印日志</a></span></dt><dd><dl><dt><span class="section"><a href="lombok.logging.html#id1030">31.4.1. lombok</a></span></dt></dl></dd><dt><span class="section"><a href="springboot.logback.html">31.5. logback 配置详解</a></span></dt><dd><dl><dt><span class="section"><a href="springboot.logback.html#logback.stdout">31.5.1. 标准输出</a></span></dt><dt><span class="section"><a href="springboot.logback.html#id1031">31.5.2. 禁止 logback 日志输出</a></span></dt><dt><span class="section"><a href="springboot.logback.html#logback.level">31.5.3. 指定Class过滤日志</a></span></dt><dt><span class="section"><a href="springboot.logback.html#logback.attr">31.5.4. configuration 属性配置</a></span></dt><dt><span class="section"><a href="springboot.logback.html#logback.contextName">31.5.5. contextName 设置上下文名称</a></span></dt><dt><span class="section"><a href="springboot.logback.html#logback.property">31.5.6. property 设置变量</a></span></dt><dt><span class="section"><a href="springboot.logback.html#logback.encoder">31.5.7. encoder 日志格式设置</a></span></dt><dt><span class="section"><a href="springboot.logback.html#RollingFileAppender">31.5.8. RollingFileAppender</a></span></dt><dt><span class="section"><a href="springboot.logback.html#id1034">31.5.9. 日志过滤</a></span></dt><dt><span class="section"><a href="springboot.logback.html#logback.file">31.5.10. 标准输出</a></span></dt><dt><span class="section"><a href="springboot.logback.html#id1035">31.5.11. MDC</a></span></dt><dt><span class="section"><a href="springboot.logback.html#logback.mongodb">31.5.12. 日志写入 MongoDB</a></span></dt><dt><span class="section"><a href="springboot.logback.html#logback.logstash">31.5.13. 日志发送给 logstash</a></span></dt><dt><span class="section"><a href="springboot.logback.html#springboot.fluentd">31.5.14. fluentd</a></span></dt><dt><span class="section"><a href="springboot.logback.html#Loki4j">31.5.15. Loki4j Logback</a></span></dt></dl></dd><dt><span class="section"><a href="log4j2-gelf-logstash.html">31.6. Log4j2 + Gelf + Logstash</a></span></dt><dd><dl><dt><span class="section"><a href="log4j2-gelf-logstash.html#id1048">31.6.1. Maven 配置</a></span></dt><dt><span class="section"><a href="log4j2-gelf-logstash.html#id1049">31.6.2. log4j2.xml 配置</a></span></dt><dt><span class="section"><a href="log4j2-gelf-logstash.html#id1050">31.6.3. Java 测试代码</a></span></dt><dt><span class="section"><a href="log4j2-gelf-logstash.html#id1051">31.6.4. Logstash 配置</a></span></dt><dt><span class="section"><a href="log4j2-gelf-logstash.html#id1052">31.6.5. 测试结果</a></span></dt><dt><span class="section"><a href="log4j2-gelf-logstash.html#id1060">31.6.6. Log4j2 更多技巧</a></span></dt></dl></dd><dt><span class="section"><a href="logging.dingtalk.html">31.7. 日志报警</a></span></dt><dd><dl><dt><span class="section"><a href="logging.dingtalk.html#id1061">31.7.1. Logstash 配置</a></span></dt><dt><span class="section"><a href="logging.dingtalk.html#id1062">31.7.2. 监控 SpringBootApplication 的启动和退出</a></span></dt></dl></dd><dt><span class="section"><a href="SpringBoot.ELK.html">31.8. Spring boot with ELK(Elasticsearch + Logstash + Kibana)</a></span></dt><dd><dl><dt><span class="section"><a href="SpringBoot.ELK.html#id1063">31.8.1. TCP 方案</a></span></dt><dt><span class="section"><a href="SpringBoot.ELK.html#id1064">31.8.2. Redis 方案</a></span></dt><dt><span class="section"><a href="SpringBoot.ELK.html#id1065">31.8.3. Kafka 方案</a></span></dt><dt><span class="section"><a href="SpringBoot.ELK.html#id1066">31.8.4. Other</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="web.html">32. Springboot with Undertow / Jetty / http2</a></span></dt><dd><dl><dt><span class="section"><a href="web.html#Undertow">32.1. Spring boot with Undertow</a></span></dt><dd><dl><dt><span class="section"><a href="web.html#id1067">32.1.1. Maven 依赖</a></span></dt><dt><span class="section"><a href="web.html#id1068">32.1.2. Application</a></span></dt><dt><span class="section"><a href="web.html#id1069">32.1.3. 相关配置</a></span></dt></dl></dd><dt><span class="section"><a href="jetty.html">32.2. Spring boot with Jetty</a></span></dt><dt><span class="section"><a href="springboot.https.html">32.3. Spring boot with HTTP2 SSL</a></span></dt><dd><dl><dt><span class="section"><a href="springboot.https.html#id1070">32.3.1. 生成自签名证书</a></span></dt><dt><span class="section"><a href="springboot.https.html#id1071">32.3.2. application.properties 配置文件</a></span></dt><dt><span class="section"><a href="springboot.https.html#id1072">32.3.3. 启动 Spring boot</a></span></dt><dt><span class="section"><a href="springboot.https.html#id1073">32.3.4. restTemplate 调用实例</a></span></dt><dt><span class="section"><a href="springboot.https.html#id1074">32.3.5. HTTP2</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="mongodb/index.html">33. Spring boot with MongoDB</a></span></dt><dd><dl><dt><span class="section"><a href="mongodb/index.html#id1075">33.1. Maven</a></span></dt><dt><span class="section"><a href="mongodb/ch33s02.html">33.2. Application</a></span></dt><dt><span class="section"><a href="mongodb/MongoTemplate.html">33.3. MongoTemplate</a></span></dt><dt><span class="section"><a href="mongodb/Repository.html">33.4. Repository</a></span></dt></dl></dd><dt><span class="chapter"><a href="mysql/index.html">34. Spring boot with MySQL</a></span></dt><dd><dl><dt><span class="section"><a href="mysql/index.html#id1076">34.1. Maven</a></span></dt><dt><span class="section"><a href="mysql/ch34s02.html">34.2. Resource</a></span></dt><dt><span class="section"><a href="mysql/ch34s03.html">34.3. Application</a></span></dt><dt><span class="section"><a href="mysql/ch34s04.html">34.4. JdbcTemplate</a></span></dt><dt><span class="section"><a href="mysql/ch34s05.html">34.5. CrudRepository</a></span></dt></dl></dd><dt><span class="chapter"><a href="oracle/index.html">35. Spring boot with Oracle</a></span></dt><dd><dl><dt><span class="section"><a href="oracle/index.html#id1077">35.1. Maven</a></span></dt><dt><span class="section"><a href="oracle/ch35s02.html">35.2. application.properties</a></span></dt><dt><span class="section"><a href="oracle/ch35s03.html">35.3. Application</a></span></dt><dt><span class="section"><a href="oracle/ch35s04.html">35.4. CrudRepository</a></span></dt><dt><span class="section"><a href="oracle/ch35s05.html">35.5. JdbcTemplate</a></span></dt><dt><span class="section"><a href="oracle/ch35s06.html">35.6. Controller</a></span></dt></dl></dd><dt><span class="chapter"><a href="postgresql/index.html">36. Spring boot with PostgreSQL</a></span></dt><dd><dl><dt><span class="section"><a href="postgresql/index.html#id1078">36.1. pom.xml</a></span></dt><dt><span class="section"><a href="postgresql/ch36s02.html">36.2. application.properties</a></span></dt><dt><span class="section"><a href="postgresql/ch36s03.html">36.3. Application</a></span></dt><dt><span class="section"><a href="postgresql/ch36s04.html">36.4. CrudRepository</a></span></dt><dt><span class="section"><a href="postgresql/ch36s05.html">36.5. JdbcTemplate</a></span></dt><dt><span class="section"><a href="postgresql/ch36s06.html">36.6. Controller</a></span></dt><dt><span class="section"><a href="postgresql/ch36s07.html">36.7. Test</a></span></dt></dl></dd><dt><span class="chapter"><a href="elasticsearch/index.html">37. Spring boot with Elasticsearch</a></span></dt><dd><dl><dt><span class="section"><a href="elasticsearch/index.html#id1079">37.1. Maven</a></span></dt><dt><span class="section"><a href="elasticsearch/ch37s02.html">37.2. Application</a></span></dt><dt><span class="section"><a href="elasticsearch/ch37s03.html">37.3. application.properties</a></span></dt><dt><span class="section"><a href="elasticsearch/ch37s04.html">37.4. Domain</a></span></dt><dt><span class="section"><a href="elasticsearch/ch37s05.html">37.5. ElasticsearchRepository</a></span></dt></dl></dd><dt><span class="chapter"><a href="elasticsearch/5.x/index.html">38. Spring boot with Elasticsearch TransportClient</a></span></dt><dd><dl><dt><span class="section"><a href="elasticsearch/5.x/index.html#id1080">38.1. Maven</a></span></dt><dt><span class="section"><a href="elasticsearch/5.x/ch38s02.html">38.2. Application</a></span></dt><dt><span class="section"><a href="elasticsearch/5.x/ch38s03.html">38.3. application.properties</a></span></dt><dt><span class="section"><a href="elasticsearch/5.x/ch38s04.html">38.4. ElasticsearchConfiguration</a></span></dt><dt><span class="section"><a href="elasticsearch/5.x/ch38s05.html">38.5. RestController</a></span></dt></dl></dd><dt><span class="chapter"><a href="hive/index.html">39. Spring boot with Apache Hive</a></span></dt><dd><dl><dt><span class="section"><a href="hive/index.html#id1081">39.1. Maven</a></span></dt><dt><span class="section"><a href="hive/ch39s02.html">39.2. application.properties</a></span></dt><dt><span class="section"><a href="hive/ch39s03.html">39.3. Configuration</a></span></dt><dt><span class="section"><a href="hive/ch39s04.html">39.4. CURD 操作实例</a></span></dt></dl></dd><dt><span class="chapter"><a href="phoenix/index.html">40. Spring boot with Phoenix</a></span></dt><dd><dl><dt><span class="section"><a href="phoenix/index.html#id1082">40.1. Maven</a></span></dt><dt><span class="section"><a href="phoenix/ch40s02.html">40.2. application.properties</a></span></dt><dt><span class="section"><a href="phoenix/ch40s03.html">40.3. Configuration</a></span></dt></dl></dd><dt><span class="chapter"><a href="datasource/index.html">41. Spring boot with Datasource</a></span></dt><dd><dl><dt><span class="section"><a href="datasource/index.html#id1086">41.1. Master / Slave 主从数据库数据源配置</a></span></dt><dd><dl><dt><span class="section"><a href="datasource/index.html#id1083">41.1.1. application.properties</a></span></dt><dt><span class="section"><a href="datasource/index.html#id1084">41.1.2. 配置主从数据源</a></span></dt><dt><span class="section"><a href="datasource/index.html#id1085">41.1.3. 选择数据源</a></span></dt></dl></dd><dt><span class="section"><a href="datasource/ch41s02.html">41.2. 多数据源配置</a></span></dt><dt><span class="section"><a href="datasource/ch41s03.html">41.3. JPA 多数据源</a></span></dt></dl></dd><dt><span class="chapter"><a href="pool/index.html">42. 连接池配置</a></span></dt><dd><dl><dt><span class="section"><a href="pool/index.html#tomcat">42.1. org.apache.tomcat.jdbc.pool.DataSource</a></span></dt><dt><span class="section"><a href="pool/pool.druid.html">42.2. druid</a></span></dt><dd><dl><dt><span class="section"><a href="pool/pool.druid.html#id1087">42.2.1. 加密数据库密码</a></span></dt></dl></dd><dt><span class="section"><a href="pool/pool.c3p0.html">42.3. c3p0 - JDBC3 Connection and Statement Pooling</a></span></dt><dt><span class="section"><a href="pool/dbcp2.html">42.4. dbcp2</a></span></dt><dt><span class="section"><a href="pool/bonecp.html">42.5. bonecp</a></span></dt><dt><span class="section"><a href="pool/HikariPool.html">42.6. HikariPool</a></span></dt></dl></dd><dt><span class="chapter"><a href="queue/index.html">43. Spring boot with Queue</a></span></dt><dd><dl><dt><span class="section"><a href="queue/index.html#rabbitmq">43.1. Spring boot with RabbitMQ(AMQP)</a></span></dt><dd><dl><dt><span class="section"><a href="queue/index.html#id1088">43.1.1. maven</a></span></dt><dt><span class="section"><a href="queue/index.html#id1089">43.1.2. RabbitMQConfig</a></span></dt><dt><span class="section"><a href="queue/index.html#id1090">43.1.3. 生产者</a></span></dt><dt><span class="section"><a href="queue/index.html#id1091">43.1.4. 消费者</a></span></dt></dl></dd><dt><span class="section"><a href="queue/kafka.html">43.2. Spring boot with Apache Kafka</a></span></dt><dd><dl><dt><span class="section"><a href="queue/kafka.html#id1092">43.2.1. 安装 kafka</a></span></dt><dt><span class="section"><a href="queue/kafka.html#maven">43.2.2. maven</a></span></dt><dt><span class="section"><a href="queue/kafka.html#application">43.2.3. Spring boot Application</a></span></dt><dt><span class="section"><a href="queue/kafka.html#EnableKafka">43.2.4. EnableKafka</a></span></dt><dt><span class="section"><a href="queue/kafka.html#KafkaListener">43.2.5. KafkaListener</a></span></dt><dt><span class="section"><a href="queue/kafka.html#spring.boot.kafka.test">43.2.6. 测试</a></span></dt><dt><span class="section"><a href="queue/kafka.html#spring.boot.kafka.example">43.2.7. 完整的发布订阅实例</a></span></dt><dt><span class="section"><a href="queue/kafka.html#spring.cloud.kafka">43.2.8. Spring cloud with Kafka</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="scheduling/index.html">44. Spring boot with Scheduling</a></span></dt><dd><dl><dt><span class="section"><a href="scheduling/index.html#id1096">44.1. 启用计划任务</a></span></dt><dd><dl><dt><span class="section"><a href="scheduling/index.html#id1093">44.1.1. Application.java</a></span></dt><dt><span class="section"><a href="scheduling/index.html#id1094">44.1.2. 配置</a></span></dt><dt><span class="section"><a href="scheduling/index.html#id1095">44.1.3. Component</a></span></dt></dl></dd><dt><span class="section"><a href="scheduling/Scheduled.matchIfMissing.html">44.2. 计划任务控制开关</a></span></dt><dt><span class="section"><a href="scheduling/scheduled.html">44.3. @Scheduled 详解</a></span></dt><dd><dl><dt><span class="section"><a href="scheduling/scheduled.html#fixedRate">44.3.1. fixedRate 案例</a></span></dt><dt><span class="section"><a href="scheduling/scheduled.html#timeUnit">44.3.2. timeUnit</a></span></dt></dl></dd><dt><span class="section"><a href="scheduling/schedule.cron.html">44.4. cron 表达式</a></span></dt><dd><dl><dt><span class="section"><a href="scheduling/schedule.cron.html#id1097">44.4.1. 每3秒钟一运行一次</a></span></dt><dt><span class="section"><a href="scheduling/schedule.cron.html#id1098">44.4.2. 凌晨23点运行</a></span></dt><dt><span class="section"><a href="scheduling/schedule.cron.html#id1099">44.4.3. 周一 ~ 周五</a></span></dt></dl></dd><dt><span class="section"><a href="scheduling/TimerTask.html">44.5. Timer 例子</a></span></dt><dt><span class="section"><a href="scheduling/ScheduledExecutorService.html">44.6. ScheduledExecutorService 例子</a></span></dt></dl></dd><dt><span class="chapter"><a href="swagger/index.html">45. Spring boot with Swagger</a></span></dt><dd><dl><dt><span class="section"><a href="swagger/index.html#springdoc">45.1. Spring boot with Springdoc</a></span></dt><dd><dl><dt><span class="section"><a href="swagger/index.html#id1100">45.1.1. WebMvc</a></span></dt><dt><span class="section"><a href="swagger/index.html#id1101">45.1.2. Webflux</a></span></dt><dt><span class="section"><a href="swagger/index.html#id1102">45.1.3. Swagger UI</a></span></dt><dt><span class="section"><a href="swagger/index.html#id1103">45.1.4. 从 SpringFox 迁移到 Swagger3 注解变化</a></span></dt></dl></dd><dt><span class="section"><a href="swagger/springboot.knife4j.html">45.2. Spring boot with knife4j</a></span></dt><dd><dl><dt><span class="section"><a href="swagger/springboot.knife4j.html#id1104">45.2.1. maven</a></span></dt><dt><span class="section"><a href="swagger/springboot.knife4j.html#id1105">45.2.2. Knife4jConfiguration</a></span></dt><dt><span class="section"><a href="swagger/springboot.knife4j.html#id1106">45.2.3. application.properties</a></span></dt></dl></dd><dt><span class="section"><a href="swagger/springfox.html">45.3. springfox</a></span></dt><dd><dl><dt><span class="section"><a href="swagger/springfox.html#id1107">45.3.1. Swagger3</a></span></dt><dt><span class="section"><a href="swagger/springfox.html#id1112">45.3.2. Swagger2</a></span></dt><dt><span class="section"><a href="swagger/springfox.html#swagger.@Api">45.3.3. @Api() 资源定义</a></span></dt><dt><span class="section"><a href="swagger/springfox.html#swagger.@ApiIgnore">45.3.4. @ApiIgnore 忽律接口</a></span></dt><dt><span class="section"><a href="swagger/springfox.html#id1114">45.3.5. @ApiOperation()</a></span></dt><dt><span class="section"><a href="swagger/springfox.html#id1115">45.3.6. @ApiResponses</a></span></dt><dt><span class="section"><a href="swagger/springfox.html#id1116">45.3.7. @ApiModel 实体类</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="lombok.html">46. Spring boot with lombok</a></span></dt><dd><dl><dt><span class="section"><a href="lombok.html#id1117">46.1. @Builder</a></span></dt><dt><span class="section"><a href="ch46s02.html">46.2. @Slf4j 注解</a></span></dt></dl></dd><dt><span class="chapter"><a href="docker/index.html">47. Spring boot with Container</a></span></dt><dd><dl><dt><span class="section"><a href="docker/index.html#springboot.docker">47.1. Spring boot with Docker</a></span></dt><dd><dl><dt><span class="section"><a href="docker/index.html#id1123">47.1.1. 通过 Docker 命令构建镜像</a></span></dt><dt><span class="section"><a href="docker/index.html#id1128">47.1.2. 通过 Maven 构建 Docker 镜像</a></span></dt><dt><span class="section"><a href="docker/index.html#id1129">47.1.3. [ERROR] No plugin found for prefix 'dockerfile' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/neo/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]</a></span></dt><dt><span class="section"><a href="docker/index.html#id1130">47.1.4. curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost:8888</a></span></dt></dl></dd><dt><span class="section"><a href="docker/spring-boot.docker-stack.html">47.2. Spring boot with Docker stack</a></span></dt><dd><dl><dt><span class="section"><a href="docker/spring-boot.docker-stack.html#id1131">47.2.1. 编译 Docker 镜像</a></span></dt><dt><span class="section"><a href="docker/spring-boot.docker-stack.html#id1132">47.2.2. </a></span></dt></dl></dd><dt><span class="section"><a href="docker/springboot.kubernetes.html">47.3. Spring boot with Kubernetes</a></span></dt><dd><dl><dt><span class="section"><a href="docker/springboot.kubernetes.html#id1133">47.3.1. Kubernetes 编排脚本</a></span></dt><dt><span class="section"><a href="docker/springboot.kubernetes.html#id1134">47.3.2. 部署镜像</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="index.html">48. Spring boot with command line</a></span></dt><dd><dl><dt><span class="section"><a href="index.html#id1135">48.1. Maven</a></span></dt><dt><span class="section"><a href="spring.command.argv.html">48.2. CommandLineRunner 例子</a></span></dt><dt><span class="section"><a href="ch48s03.html">48.3. ApplicationRunner 例子</a></span></dt></dl></dd><dt><span class="chapter"><a href="actuator/index.html">49. Spring Boot Actuator</a></span></dt><dd><dl><dt><span class="section"><a href="actuator/index.html#id1136">49.1. Maven 依赖</a></span></dt><dt><span class="section"><a href="actuator/actuator.config.html">49.2. 与 Spring Boot Actuator 有关的配置</a></span></dt><dd><dl><dt><span class="section"><a href="actuator/actuator.config.html#id1137">49.2.1. 禁用HTTP端点</a></span></dt><dt><span class="section"><a href="actuator/actuator.config.html#id1138">49.2.2. 安全配置</a></span></dt><dt><span class="section"><a href="actuator/actuator.config.html#actuator.path">49.2.3. 修改 actuator 地址</a></span></dt><dt><span class="section"><a href="actuator/actuator.config.html#id1139">49.2.4. 关机</a></span></dt></dl></dd><dt><span class="section"><a href="actuator/actuator.address.html">49.3. actuator 接口</a></span></dt><dt><span class="section"><a href="actuator/actuator.health.html">49.4. 健康状态</a></span></dt><dd><dl><dt><span class="section"><a href="actuator/actuator.health.html#id1140">49.4.1. 健康状态</a></span></dt><dt><span class="section"><a href="actuator/actuator.health.html#actuator.health.custom">49.4.2. 自定义健康检查</a></span></dt></dl></dd><dt><span class="section"><a href="actuator/actuator.info.html">49.5. info 配置信息</a></span></dt><dd><dl><dt><span class="section"><a href="actuator/actuator.info.html#id1143">49.5.1. application.properties 配置静态信息</a></span></dt><dt><span class="section"><a href="actuator/actuator.info.html#id1144">49.5.2. 动态信息</a></span></dt></dl></dd><dt><span class="section"><a href="actuator/actuator.beans.html">49.6. beans 信息</a></span></dt><dt><span class="section"><a href="actuator/actuator.caches.html">49.7. caches</a></span></dt><dt><span class="section"><a href="actuator/actuator.conditions.html">49.8. conditions</a></span></dt><dt><span class="section"><a href="actuator/actuator.configprops.html">49.9. configprops 配置文件</a></span></dt><dt><span class="section"><a href="actuator/actuator.env.html">49.10. env 环境变量</a></span></dt><dt><span class="section"><a href="actuator/actuator.logfile.html">49.11. logfile 日志</a></span></dt><dt><span class="section"><a href="actuator/actuator.threaddump.html">49.12. threaddump 线程信息</a></span></dt><dt><span class="section"><a href="actuator/actuator.scheduledtasks.html">49.13. 计划任务</a></span></dt><dt><span class="section"><a href="actuator/actuator.metrics.html">49.14. metrics</a></span></dt><dt><span class="section"><a href="actuator/actuator.mappings.html">49.15. 控制器映射 URL</a></span></dt><dt><span class="section"><a href="actuator/actuator.endpoint.html">49.16. 自定义监控指标</a></span></dt></dl></dd><dt><span class="chapter"><a href="test/index.html">50. SpringBootTest</a></span></dt><dd><dl><dt><span class="section"><a href="test/index.html#springboot.test.maven">50.1. Maven 依赖</a></span></dt><dt><span class="section"><a href="test/test.class.html">50.2. 测试类</a></span></dt><dd><dl><dt><span class="section"><a href="test/test.class.html#spring.boot.test">50.2.1. Junit基本注解介绍</a></span></dt></dl></dd><dt><span class="section"><a href="test/Assert.html">50.3. </a></span></dt><dd><dl><dt><span class="section"><a href="test/Assert.html#Assert.assertEquals">50.3.1. Assert.assertEquals 判断相等</a></span></dt><dt><span class="section"><a href="test/Assert.html#Assert.assertTrue">50.3.2. Assert.assertTrue</a></span></dt></dl></dd><dt><span class="section"><a href="test/ch50s04.html">50.4. JPA 测试</a></span></dt><dt><span class="section"><a href="test/ch50s05.html">50.5. TestRestTemplate</a></span></dt><dt><span class="section"><a href="test/MockMvc.html">50.6. Controller单元测试</a></span></dt><dt><span class="section"><a href="test/WebTestClient.html">50.7. WebTestClient</a></span></dt></dl></dd><dt><span class="chapter"><a href="spring.aop.html">51. Spring boot with Aop</a></span></dt><dd><dl><dt><span class="section"><a href="spring.aop.html#Aspect">51.1. Aspect</a></span></dt><dd><dl><dt><span class="section"><a href="spring.aop.html#id1145">51.1.1. Maven</a></span></dt><dt><span class="section"><a href="spring.aop.html#id1146">51.1.2. Pojo 类</a></span></dt><dt><span class="section"><a href="spring.aop.html#id1147">51.1.3. Service 类</a></span></dt><dt><span class="section"><a href="spring.aop.html#id1148">51.1.4. Aspect 类</a></span></dt><dt><span class="section"><a href="spring.aop.html#id1149">51.1.5. 控制器</a></span></dt><dt><span class="section"><a href="spring.aop.html#id1150">51.1.6. Application</a></span></dt><dt><span class="section"><a href="spring.aop.html#id1151">51.1.7. 测试</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="springboot.starter.html">52. Spring boot with starter</a></span></dt><dd><dl><dt><span class="section"><a href="springboot.starter.html#id1156">52.1. 实现 starter</a></span></dt><dd><dl><dt><span class="section"><a href="springboot.starter.html#id1152">52.1.1. Maven pom.xml 依赖包</a></span></dt><dt><span class="section"><a href="springboot.starter.html#id1153">52.1.2. 配置文件处理</a></span></dt><dt><span class="section"><a href="springboot.starter.html#id1154">52.1.3. 自动配置文件</a></span></dt><dt><span class="section"><a href="springboot.starter.html#id1155">52.1.4. 启用 starter 的自定义注解</a></span></dt></dl></dd><dt><span class="section"><a href="ch52s02.html">52.2. 引用 starter</a></span></dt><dd><dl><dt><span class="section"><a href="ch52s02.html#id1157">52.2.1. Maven pom.xml 引入依赖</a></span></dt><dt><span class="section"><a href="ch52s02.html#id1158">52.2.2. 通过注解配置 starter</a></span></dt><dt><span class="section"><a href="ch52s02.html#id1159">52.2.3. 测试运行结果</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="monitor/index.html">53. Spring boot with Monitor</a></span></dt><dd><dl><dt><span class="section"><a href="monitor/index.html#springboot.grafana">53.1. Spring boot with Grafana</a></span></dt><dd><dl><dt><span class="section"><a href="monitor/index.html#id1160">53.1.1. Springboot 集成 InfluxDB</a></span></dt><dt><span class="section"><a href="monitor/index.html#id1161">53.1.2. InfluxDB</a></span></dt></dl></dd><dt><span class="section"><a href="monitor/springboot.prometheus.html">53.2. Spring Boot with Prometheus</a></span></dt><dd><dl><dt><span class="section"><a href="monitor/springboot.prometheus.html#id1162">53.2.1. Maven 依赖</a></span></dt><dt><span class="section"><a href="monitor/springboot.prometheus.html#id1163">53.2.2. application.properties 配置文件</a></span></dt><dt><span class="section"><a href="monitor/springboot.prometheus.html#id1164">53.2.3. 启动类</a></span></dt><dt><span class="section"><a href="monitor/springboot.prometheus.html#id1165">53.2.4. 测试</a></span></dt><dt><span class="section"><a href="monitor/springboot.prometheus.html#id1166">53.2.5. 控制器监控</a></span></dt><dt><span class="section"><a href="monitor/springboot.prometheus.html#id1171">53.2.6. 自定义埋点监控</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="git/index.html">55. Spring boot with Git version</a></span></dt><dd><dl><dt><span class="section"><a href="git/index.html#id1172">55.1. CommonRestController 公共控制器</a></span></dt><dt><span class="section"><a href="git/ch55s02.html">55.2. VersionRestController 测试控制器</a></span></dt><dt><span class="section"><a href="git/ch55s03.html">55.3. 创建 .gitattributes 文件</a></span></dt></dl></dd><dt><span class="chapter"><a href="session/index.html">56. Spring boot with Session share</a></span></dt><dd><dl><dt><span class="section"><a href="session/index.html#id1176">56.1. Redis</a></span></dt><dd><dl><dt><span class="section"><a href="session/index.html#id1173">56.1.1. Maven</a></span></dt><dt><span class="section"><a href="session/index.html#id1174">56.1.2. application.properties</a></span></dt><dt><span class="section"><a href="session/index.html#id1175">56.1.3. Application</a></span></dt></dl></dd><dt><span class="section"><a href="session/ch56s02.html">56.2. 测试 Session</a></span></dt><dt><span class="section"><a href="session/ch56s03.html">56.3. JDBC</a></span></dt><dt><span class="section"><a href="session/ch56s04.html">56.4. Springboot 2.1</a></span></dt></dl></dd><dt><span class="chapter"><a href="cache/index.html">57. Spring boot with Caching</a></span></dt><dd><dl><dt><span class="section"><a href="cache/index.html#id1178">57.1. maven</a></span></dt><dd><dl><dt><span class="section"><a href="cache/index.html#id1177">57.1.1. Redis</a></span></dt></dl></dd><dt><span class="section"><a href="cache/@EnableCaching.html">57.2. 启用缓存 @EnableCaching</a></span></dt><dt><span class="section"><a href="cache/@Cacheable.html">57.3. 设置缓存 @Cacheable</a></span></dt><dd><dl><dt><span class="section"><a href="cache/@Cacheable.html#id1179">57.3.1. 多参数处理</a></span></dt><dt><span class="section"><a href="cache/@Cacheable.html#id1180">57.3.2. 对象参数</a></span></dt><dt><span class="section"><a href="cache/@Cacheable.html#id1181">57.3.3. </a></span></dt><dt><span class="section"><a href="cache/@Cacheable.html#id1182">57.3.4. 参数索引</a></span></dt><dt><span class="section"><a href="cache/@Cacheable.html#id1183">57.3.5. 自动生成 key</a></span></dt><dt><span class="section"><a href="cache/@Cacheable.html#id1184">57.3.6. SpEL表达式</a></span></dt><dt><span class="section"><a href="cache/@Cacheable.html#id1185">57.3.7. 排除 null 结果</a></span></dt><dt><span class="section"><a href="cache/@Cacheable.html#result.empty">57.3.8. 排除 empty</a></span></dt></dl></dd><dt><span class="section"><a href="cache/@CachePut.html">57.4. 更新缓存 @CachePut</a></span></dt><dt><span class="section"><a href="cache/@CacheEvict.html">57.5. 删除缓存 @CacheEvict</a></span></dt><dt><span class="section"><a href="cache/@Caching.html">57.6. 组合操作 @Caching</a></span></dt><dt><span class="section"><a href="cache/ch57s07.html">57.7. 序列化</a></span></dt><dt><span class="section"><a href="cache/解决Expire 和 TTL 过期时间.html">57.8. 解决Expire 和 TTL 过期时间</a></span></dt><dt><span class="section"><a href="cache/cache.serializer.html">57.9. Cannot serialize</a></span></dt></dl></dd><dt><span class="chapter"><a href="email/index.html">58. Spring boot with Email</a></span></dt><dd><dl><dt><span class="section"><a href="email/index.html#jakarta.mail">58.1. jakarta.mail</a></span></dt><dt><span class="section"><a href="email/spring-boot-starter-mail.html">58.2. spring-boot-starter-mail</a></span></dt><dd><dl><dt><span class="section"><a href="email/spring-boot-starter-mail.html#id1186">58.2.1. Maven</a></span></dt><dt><span class="section"><a href="email/spring-boot-starter-mail.html#id1187">58.2.2. Resource</a></span></dt><dt><span class="section"><a href="email/spring-boot-starter-mail.html#id1188">58.2.3. POJO</a></span></dt><dt><span class="section"><a href="email/spring-boot-starter-mail.html#id1189">58.2.4. RestController</a></span></dt><dt><span class="section"><a href="email/spring-boot-starter-mail.html#id1190">58.2.5. Test</a></span></dt></dl></dd><dt><span class="section"><a href="email/spring-boot-starter-mail.detail.html">58.3. 用法详解</a></span></dt><dd><dl><dt><span class="section"><a href="email/spring-boot-starter-mail.detail.html#id1191">58.3.1. 开启 DEBUG</a></span></dt><dt><span class="section"><a href="email/spring-boot-starter-mail.detail.html#id1192">58.3.2. SMTP SSL 配置</a></span></dt><dt><span class="section"><a href="email/spring-boot-starter-mail.detail.html#id1193">58.3.3. SMTP TLS 配置</a></span></dt><dt><span class="section"><a href="email/spring-boot-starter-mail.detail.html#id1194">58.3.4. 发送文本邮件</a></span></dt><dt><span class="section"><a href="email/spring-boot-starter-mail.detail.html#id1195">58.3.5. 发送HTML邮件</a></span></dt><dt><span class="section"><a href="email/spring-boot-starter-mail.detail.html#id1196">58.3.6. 发送带附件的邮件</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="hessian/index.html">59. Spring boot with Hessian</a></span></dt><dd><dl><dt><span class="section"><a href="hessian/index.html#id1197">59.1. Maven</a></span></dt><dt><span class="section"><a href="hessian/ch59s02.html">59.2. Application</a></span></dt><dt><span class="section"><a href="hessian/ch59s03.html">59.3. HessianServiceExporter</a></span></dt><dt><span class="section"><a href="hessian/ch59s04.html">59.4. Service</a></span></dt><dt><span class="section"><a href="hessian/ch59s05.html">59.5. RestController</a></span></dt></dl></dd><dt><span class="chapter"><a href="async/index.html">60. Spring boot with Async</a></span></dt><dd><dl><dt><span class="section"><a href="async/index.html#Callable">60.1. Callable 实现异步</a></span></dt><dt><span class="section"><a href="async/WebAsyncTask.html">60.2. WebAsyncTask 实现异步</a></span></dt><dt><span class="section"><a href="async/DeferredResult.html">60.3. DeferredResult 实现异步返回结果</a></span></dt><dt><span class="section"><a href="async/ch60s04.html">60.4. 带有返回值的异步任务</a></span></dt><dd><dl><dt><span class="section"><a href="async/ch60s04.html#id1198">60.4.1. Future</a></span></dt><dt><span class="section"><a href="async/ch60s04.html#id1199">60.4.2. CompletableFuture</a></span></dt></dl></dd><dt><span class="section"><a href="async/SimpleAsyncTaskExecutor.html">60.5. 默认简单线程池 SimpleAsyncTaskExecutor</a></span></dt><dd><dl><dt><span class="section"><a href="async/SimpleAsyncTaskExecutor.html#id1200">60.5.1. 配置线程池</a></span></dt><dt><span class="section"><a href="async/SimpleAsyncTaskExecutor.html#id1201">60.5.2. @Service/@Component 中异步执行</a></span></dt><dt><span class="section"><a href="async/SimpleAsyncTaskExecutor.html#id1202">60.5.3. applicationTaskExecutor</a></span></dt></dl></dd><dt><span class="section"><a href="async/ThreadPoolTaskExecutor.html">60.6. ThreadPoolTaskExecutor 自定义线程池</a></span></dt><dd><dl><dt><span class="section"><a href="async/ThreadPoolTaskExecutor.html#简单异步执行">60.6.1. 最简单的配置</a></span></dt><dt><span class="section"><a href="async/ThreadPoolTaskExecutor.html#id1203">60.6.2. 队列</a></span></dt><dt><span class="section"><a href="async/ThreadPoolTaskExecutor.html#id1204">60.6.3. 定义多个线程池</a></span></dt><dt><span class="section"><a href="async/ThreadPoolTaskExecutor.html#id1205">60.6.4. 实现 AsyncConfigurer 接口方式创建自定义连接池</a></span></dt><dt><span class="section"><a href="async/ThreadPoolTaskExecutor.html#id1206">60.6.5. 继承 AsyncConfigurerSupport 创建自定义连接池 </a></span></dt><dt><span class="section"><a href="async/ThreadPoolTaskExecutor.html#id1207">60.6.6. 生产环境完整代码 @Bean 注入方式</a></span></dt><dt><span class="section"><a href="async/ThreadPoolTaskExecutor.html#id1208">60.6.7. 通过 @Bean 覆盖掉 SimpleAsyncTaskExecutor</a></span></dt></dl></dd><dt><span class="section"><a href="async/ThreadPoolExecutor.html">60.7. 自定义线程池 ThreadPoolExecutor</a></span></dt><dd><dl><dt><span class="section"><a href="async/ThreadPoolExecutor.html#id1209">60.7.1. ThreadPoolExecutor</a></span></dt><dt><span class="section"><a href="async/ThreadPoolExecutor.html#id1210">60.7.2. 注入自定义线程池bean</a></span></dt></dl></dd><dt><span class="section"><a href="async/ch60s08.html">60.8. 设置线程名称</a></span></dt><dt><span class="section"><a href="async/ch60s09.html">60.9. 线程池监控</a></span></dt><dt><span class="section"><a href="async/ch60s10.html">60.10. 注意事项</a></span></dt></dl></dd><dt><span class="chapter"><a href="web3j.html">61. Springboot with Ethereum (web3j)</a></span></dt><dd><dl><dt><span class="section"><a href="web3j.html#id1211">61.1. Maven</a></span></dt><dt><span class="section"><a href="web3j.springboot.application.properties.html">61.2. application.properties</a></span></dt><dt><span class="section"><a href="ch61s03.html">61.3. TestRestController</a></span></dt><dt><span class="section"><a href="ch61s04.html">61.4. 测试</a></span></dt></dl></dd><dt><span class="chapter"><a href="record/index.html">62. Java Record 新特性</a></span></dt><dd><dl><dt><span class="section"><a href="record/index.html#id1212">62.1. Record 替代 POJO 类</a></span></dt><dt><span class="section"><a href="record/ch62s02.html">62.2. Record 作为 Properties</a></span></dt><dt><span class="section"><a href="record/ch62s03.html">62.3. Record 作为实体类</a></span></dt><dt><span class="section"><a href="record/ch62s04.html">62.4. Record 作为 Service</a></span></dt><dt><span class="section"><a href="record/spring.boot.record.html">62.5. Record 作为 Controller</a></span></dt></dl></dd><dt><span class="chapter"><a href="Retryable.html">63. Spring boot with Retryable</a></span></dt><dd><dl><dt><span class="section"><a href="Retryable.html#spring.EnableResilientMethods">63.1. @EnableResilientMethods</a></span></dt><dd><dl><dt><span class="section"><a href="Retryable.html#spring.ConcurrencyLimit">63.1.1. @ConcurrencyLimit 限流</a></span></dt><dt><span class="section"><a href="Retryable.html#spring.Retryable">63.1.2. @Retryable 重试</a></span></dt></dl></dd><dt><span class="section"><a href="ch63s02.html">63.2. spring-retry</a></span></dt><dd><dl><dt><span class="section"><a href="ch63s02.html#id1213">63.2.1. spring-retry 依赖</a></span></dt><dt><span class="section"><a href="ch63s02.html#id1214">63.2.2. @EnableRetry 启用重试</a></span></dt><dt><span class="section"><a href="ch63s02.html#id1215">63.2.3. </a></span></dt><dt><span class="section"><a href="ch63s02.html#id1216">63.2.4. 高级用法</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href=".html">64. Spring Boot 4 + OpenTelemetry</a></span></dt><dd><dl><dt><span class="section"><a href=".html#id1217">64.1. 依赖配置</a></span></dt><dt><span class="section"><a href="ch64s02.html">64.2. 定义 Span</a></span></dt><dt><span class="section"><a href="ch64s03.html">64.3. 日志追踪</a></span></dt></dl></dd></dl></div>
<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="redis"></a>1. Spring boot with Redis</h2></div></div></div>
<div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="redis"></a>1.1. Spring boot with Redis</h3></div></div></div>
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="id2153"></a>1.1.1. maven</h4></div></div></div>
<pre class="programlisting">
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
</pre>
</div>
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="id2154"></a>1.1.2. application.properties</h4></div></div></div>
<pre class="programlisting">
spring.redis.database=10
spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=
spring.redis.pool.max-active=8
spring.redis.pool.max-wait=-1
spring.redis.pool.max-idle=8
spring.redis.pool.min-idle=0
spring.redis.timeout=0
</pre>
</div>
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="id2155"></a>1.1.3. JUnit</h4></div></div></div>
<pre class="programlisting">
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(Application.class)
public class ApplicationTests {
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Test
public void test() throws Exception {
// 保存字符串
stringRedisTemplate.opsForValue().set("neo", "chen");
Assert.assertEquals("chen", stringRedisTemplate.opsForValue().get("neo"));
}
}
</pre>
</div>
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="id2156"></a>1.1.4. Controller</h4></div></div></div>
<p>stringRedisTemplate模板用于存储key,value为字符串的数据</p>
<pre class="programlisting">
@Autowired
private StringRedisTemplate stringRedisTemplate;
@RequestMapping("/test")
@ResponseBody
public String test() {
String message = "";
stringRedisTemplate.opsForValue().set("hello", "world");
message = stringRedisTemplate.opsForValue().get("hello");
return message;
}
</pre>
<p>等同于</p>
<pre class="programlisting">
@Autowired
private RedisTemplate<String, String> redisTemplate;
</pre>
<div class="example"><a id="id2032"></a><p class="title"><strong>例 8. RedisTemplate</strong></p><div class="example-contents">
<pre class="programlisting">
@Autowired
private RedisTemplate<String, String> redisTemplate;
public List<Protocol> getProtocol() {
List<Protocol> protocols = new ArrayList<Protocol>();
Gson gson = new Gson();
Type type = new TypeToken<List<Protocol>>(){}.getType();
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new StringRedisSerializer());
String cacheKey = String.format("%s:%s", this.getClass().getName(), Thread.currentThread().getStackTrace()[1].getMethodName());
long expireTime = 5;
if(redisTemplate.hasKey(cacheKey)){
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
System.out.println(cacheValue);
protocols = gson.fromJson(cacheValue, type);
}else{
Protocol protocol = new Protocol();
protocol.setRequest(new Date().toString());
protocols.add(protocol);
String jsonString = gson.toJson(protocols, type);
System.out.println( jsonString );
redisTemplate.opsForValue().set(cacheKey, jsonString);
redisTemplate.expire(cacheKey, expireTime, TimeUnit.SECONDS);
}
return protocols;
}
</pre>
</div></div><br class="example-break" />
</div>
</div>
<div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="redis.pubsub"></a>1.2. Redis Pub/Sub</h3></div></div></div>
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="id2157"></a>1.2.1. Redis配置类</h4></div></div></div>
<pre class="programlisting">
package cn.netkiller.wallet.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import cn.netkiller.wallet.redis.RedisMessageSubscriber;
@Configuration
public class RedisConfig {
public RedisConfig() {
}
@Bean
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory connectionFactory) {
StringRedisTemplate redisTemplate = new StringRedisTemplate();
redisTemplate.setConnectionFactory(connectionFactory);
return redisTemplate;
}
@Bean
public MessageListenerAdapter messageListener() {
return new MessageListenerAdapter(new RedisMessageSubscriber());
}
@Bean
public ChannelTopic topic() {
return new ChannelTopic("demo");
}
@Bean
public RedisMessageListenerContainer redisContainer(RedisConnectionFactory connectionFactory, MessageListenerAdapter messageListener) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.addMessageListener(messageListener(), topic());
container.addMessageListener(messageListener(), new ChannelTopic("test"));
return container;
}
}
</pre>
</div>
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="id2158"></a>1.2.2. 订阅类</h4></div></div></div>
<pre class="programlisting">
package cn.netkiller.wallet.redis;
import java.nio.charset.StandardCharsets;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
public class RedisMessageSubscriber implements MessageListener {
public void onMessage(final Message message, final byte[] pattern) {
System.out.println("Topic : " + new String(message.getChannel(), StandardCharsets.UTF_8));
System.out.println("Message : " + message.toString());
}
}
</pre>
</div>
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="id2159"></a>1.2.3. 发布类</h4></div></div></div>
<pre class="programlisting">
package cn.netkiller.wallet.redis;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic;
public class RedisMessagePublisher {
private final StringRedisTemplate redisTemplate;
private final ChannelTopic topic;
public RedisMessagePublisher(StringRedisTemplate redisTemplate, ChannelTopic topic) {
this.redisTemplate = redisTemplate;
this.topic = topic;
}
public void publish(String message) {
redisTemplate.convertAndSend(topic.getTopic(), message);
}
}
</pre>
</div>
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="id2160"></a>1.2.4. 消息发布演示</h4></div></div></div>
<pre class="programlisting">
@Autowired
private StringRedisTemplate stringRedisTemplate;
@GetMapping("/pub/demo")
public String pub() {
RedisMessagePublisher publisher = new RedisMessagePublisher(stringRedisTemplate, new ChannelTopic("demo"));
String message = "Message " + UUID.randomUUID();
publisher.publish(message);
return message;
}
@GetMapping("/pub/test")
public String pub(@RequestParam String message) {
RedisMessagePublisher publisher = new RedisMessagePublisher(stringRedisTemplate, new ChannelTopic("test"));
publisher.publish(message);
return message;
}
</pre>
</div>
</div>
<div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="redisson"></a>1.3. Sprint boot with Redisson</h3></div></div></div>
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="id2161"></a>1.3.1. Springboot 3.x</h4></div></div></div>
<pre class="screen">
</pre>
</div>
<div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="id2162"></a>1.3.2. Springboot 2.1</h4></div></div></div>
<p>注意:排除 redisson-spring-data-23,引用 redisson-spring-data-21</p>
<pre class="screen">
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.14.0</version>
<exclusions>
<exclusion>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data-23</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data-21</artifactId>
<version>3.14.0</version>
</dependency>
</pre>
</div>
</div>
</div>
</div><script xmlns="" type="text/javascript" id="clustrmaps" src="//cdn.clustrmaps.com/map_v2.js?u=r5HG&d=9mi5r_kkDC8uxG8HuY3p4-2qgeeVypAK9vMD-2P6BYM"></script><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="../build/jitpack.html">上一页</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="spring.boot.quickstart.html">下一页</a></td></tr><tr><td width="40%" align="left" valign="top">第 25 章 JitPack - Easy to use package repository for Git </td><td width="20%" align="center"><a accesskey="h" href="../index.html">起始页</a></td><td width="40%" align="right" valign="top"> 第 26 章 Spring Boot Quick start</td></tr></table></div><script xmlns="">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-11694057-1', 'auto');
ga('send', 'pageview');
</script><script xmlns="" async="async">
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?93967759a51cda79e49bf4e34d0b0f2c";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script><script xmlns="" async="async">
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script></body></html>