-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava-parameter-and-bean-validation.html
More file actions
556 lines (444 loc) · 61.7 KB
/
java-parameter-and-bean-validation.html
File metadata and controls
556 lines (444 loc) · 61.7 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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Spring Boot 项目参数校验的常见使用场景 | happyJared - 博客</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="keywords" content="happyJared - 博客。保持勤學習的心,做好寫代碼這事。公众号:超级码里奥" />
<meta name="description" content="可以说几乎所有的应用场景中,参数验证都在编写业务逻辑前完成,严格确保进来的数据是合法且符合要求的。 Java Web 开发领域,也早有较为完善的 Bean Validation 为 Java Bean 验证定义了相应的元数据模型和 API。首先,在项目中引入 web 模块的依赖: &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot">
<meta name="keywords" content="Spring Boot,JSR 303">
<meta property="og:type" content="article">
<meta property="og:title" content="Spring Boot 项目参数校验的常见使用场景">
<meta property="og:url" content="https://blog.mariojd.cn/java-parameter-and-bean-validation.html">
<meta property="og:site_name" content="happyJared - 博客">
<meta property="og:description" content="可以说几乎所有的应用场景中,参数验证都在编写业务逻辑前完成,严格确保进来的数据是合法且符合要求的。 Java Web 开发领域,也早有较为完善的 Bean Validation 为 Java Bean 验证定义了相应的元数据模型和 API。首先,在项目中引入 web 模块的依赖: &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://image.mariojd.cn/happyjared/2019131/20190131152348.png">
<meta property="og:updated_time" content="2019-06-02T11:41:35.965Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Spring Boot 项目参数校验的常见使用场景">
<meta name="twitter:description" content="可以说几乎所有的应用场景中,参数验证都在编写业务逻辑前完成,严格确保进来的数据是合法且符合要求的。 Java Web 开发领域,也早有较为完善的 Bean Validation 为 Java Bean 验证定义了相应的元数据模型和 API。首先,在项目中引入 web 模块的依赖: &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot">
<meta name="twitter:image" content="http://image.mariojd.cn/happyjared/2019131/20190131152348.png">
<link rel="icon" href="/favicon.ico">
<link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="/css/style.css">
<script src="/js/pace.min.js"></script>
<!-- Google Analytics -->
<script type="text/javascript">
(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-127138870-1', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?7d6076888c62ff336f5b580c57fd4141";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<div style="display: none;">
<script src="//s22.cnzz.com/z_stat.php?id=1274993267&web_id=1274993267" language="JavaScript"></script>
</div>
</head>
<body>
<div id="container">
<header id="header">
<!--<div id="banner"></div>-->
<div id="header-outer">
<div id="header-menu" class="header-menu-pos animated">
<div class="header-menu-container">
<a href="/" class="left">
<span class="site-title"></span>
</a>
<nav id="header-menu-nav" class="right">
<a href="/">
<i class="fa fa-h-square"></i>
<span>主页</span>
</a>
<a href="/life">
<i class="fa fa-battery-three-quarters"></i>
<span>岁月</span>
</a>
<a target="_blank" href="https://mp.mariojd.cn">
<i class="fa fa-dot-circle-o"></i>
<span>洞见</span>
</a>
<a href="/archives">
<i class="fa fa-window-restore"></i>
<span>归档</span>
</a>
<a target="_blank" href="http://jianshu.mariojd.cn">
<i class="fa fa-superpowers"></i>
<span>简统</span>
</a>
<a href="/about">
<i class="fa fa-user"></i>
<span>关于</span>
</a>
</nav>
<a class="mobile-header-menu-button">
<i class="fa fa-bars"></i>
</a>
</div>
</div>
<div id="header-row">
<div id="logo">
<a href="/">
<img src="/images/logo.png" alt="logo">
</a>
</div>
<div class="header-info">
<!--<div id="header-title">-->
<!---->
<!--</div>-->
<div id="header-description">
<div id="hitokoto" style="height:24px;line-height:24px;">
保持勤學習的心,做好寫代碼這事
</div>
</div>
</div>
<nav class="header-nav">
<div class="social">
<a title="github" target="_blank" href="//github.com/happyjared">
<i class="fa fa-github fa-2x"></i></a>
<a title="简书" target="_blank" href="//www.jianshu.com/u/000a530f461c">
<i class="fa fa-book fa-2x"></i></a>
<a title="企鹅号" target="_blank" href="//wpa.qq.com/msgrd?v=3&uin=1394223902&site=qq&menu=yes">
<i class="fa fa-qq fa-2x"></i></a>
<a title="公众号" target="_blank" href="//image.mariojd.cn/qrcode_for_supermmario_1280.jpg">
<i class="fa fa-wechat fa-2x"></i></a>
</div>
</nav>
</div>
</div>
</header>
<div class="outer">
<section id="main" class="body-wrap"><article id="post-Java 服务端参数校验 - JSR 303介绍及实践" class="article article-type-post" itemscope itemprop="blogPost">
<div class="article-inner">
<header class="article-header">
<h1 class="post-title" itemprop="name">
Spring Boot 项目参数校验的常见使用场景
</h1>
<div class="post-title-bar">
<ul>
<li>
<i class="fa fa-book"></i>
<a href="/categories/Java/">Java</a>
</li>
<li>
<i class="fa fa-calendar"></i> 2019-01-30
</li>
<li>
<i class="fa fa-eye"></i>
<span id="busuanzi_value_page_pv"></span>
</li>
</ul>
</div>
</header>
<div class="article-entry post-content" itemprop="articleBody">
<!--
self_category:
self_tags:
osChina_sys_category:
csdn_article_category:
csdn_blog_category:
-->
<p>可以说几乎所有的应用场景中,参数验证都在编写业务逻辑前完成,严格确保进来的数据是合法且符合要求的。</p>
<p>Java Web 开发领域,也早有较为完善的 Bean Validation 为 Java Bean 验证定义了相应的元数据模型和 API。首先,在项目中引入 web 模块的依赖:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"><dependency></span><br><span class="line"> <groupId>org.springframework.boot</groupId></span><br><span class="line"> <artifactId>spring-boot-starter-web</artifactId></span><br><span class="line"></dependency></span><br></pre></td></tr></table></figure>
<p><img src="http://image.mariojd.cn/happyjared/2019131/20190131152348.png" alt="hibernate-validator"></p>
<blockquote>
<p>Hibernate Validator 是 Bean Validation 的一种实现 . Hibernate Validator 提供了 JSR 303 规范中所有内置 constraint 的实现,以及一些附加的 constraint。如果想了解更多请查看 <a href="http://www.hibernate.org/subprojects/validator.html" target="_blank" rel="noopener">http://www.hibernate.org/subprojects/validator.html</a></p>
</blockquote>
<p>具体以及常用的 constraint 包含如下:</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@Data</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Validate</span> </span>{</span><br><span class="line"></span><br><span class="line"> <span class="comment">// 空和非空检查: @Null、@NotNull、@NotBlank、@NotEmpty</span></span><br><span class="line"></span><br><span class="line"> <span class="meta">@Null</span>(message = <span class="string">"验证是否为 null"</span>)</span><br><span class="line"> <span class="keyword">private</span> Integer isNull;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@NotNull</span>(message = <span class="string">"验证是否不为 null, 但无法查检长度为0的空字符串"</span>)</span><br><span class="line"> <span class="keyword">private</span> Integer id;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@NotBlank</span>(message = <span class="string">"检查字符串是不是为 null,以及去除空格后长度是否大于0"</span>)</span><br><span class="line"> <span class="keyword">private</span> String name;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@NotEmpty</span>(message = <span class="string">"检查是否为 NULL 或者是 EMPTY"</span>)</span><br><span class="line"> <span class="keyword">private</span> List<String> stringList;</span><br><span class="line"></span><br><span class="line"> <span class="comment">// Boolean值检查: @AssertTrue、@AssertFalse</span></span><br><span class="line"></span><br><span class="line"> <span class="meta">@AssertTrue</span>(message = <span class="string">" 验证 Boolean参数是否为 true"</span>)</span><br><span class="line"> <span class="keyword">private</span> Boolean isTrue;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@AssertFalse</span>(message = <span class="string">"验证 Boolean 参数是否为 false "</span>)</span><br><span class="line"> <span class="keyword">private</span> Boolean isFalse;</span><br><span class="line"></span><br><span class="line"> <span class="comment">// 长度检查: @Size、@Length</span></span><br><span class="line"></span><br><span class="line"> <span class="meta">@Size</span>(min = <span class="number">1</span>, max = <span class="number">2</span>, message = <span class="string">"验证(Array,Collection,Map,String)长度是否在给定范围内"</span>)</span><br><span class="line"> <span class="keyword">private</span> List<Integer> integerList;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@Length</span>(min = <span class="number">8</span>, max = <span class="number">30</span>, message = <span class="string">"验证字符串长度是否在给定范围内"</span>)</span><br><span class="line"> <span class="keyword">private</span> String address;</span><br><span class="line"></span><br><span class="line"> <span class="comment">// 日期检查: @Future、@FutureOrPresent、@Past、@PastOrPresent</span></span><br><span class="line"></span><br><span class="line"> <span class="meta">@Future</span>(message = <span class="string">"验证日期是否在当前时间之后"</span>)</span><br><span class="line"> <span class="keyword">private</span> Date futureDate;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@FutureOrPresent</span>(message = <span class="string">"验证日期是否为当前时间或之后"</span>)</span><br><span class="line"> <span class="keyword">private</span> Date futureOrPresentDate;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@Past</span>(message = <span class="string">"验证日期是否在当前时间之前"</span>)</span><br><span class="line"> <span class="keyword">private</span> Date pastDate;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@PastOrPresent</span>(message = <span class="string">"验证日期是否为当前时间或之前"</span>)</span><br><span class="line"> <span class="keyword">private</span> Date pastOrPresentDate;</span><br><span class="line"></span><br><span class="line"> <span class="comment">// 其它检查: @Email、@CreditCardNumber、@URL、@Pattern、@ScriptAssert、@UniqueElements</span></span><br><span class="line"></span><br><span class="line"> <span class="meta">@Email</span>(message = <span class="string">"校验是否为正确的邮箱格式"</span>)</span><br><span class="line"> <span class="keyword">private</span> String email;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@CreditCardNumber</span>(message = <span class="string">"校验是否为正确的信用卡号"</span>)</span><br><span class="line"> <span class="keyword">private</span> String creditCardNumber;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@URL</span>(protocol = <span class="string">"http"</span>, host = <span class="string">"127.0.0.1"</span>, port = <span class="number">8080</span>, message = <span class="string">"校验是否为正确的URL地址"</span>)</span><br><span class="line"> <span class="keyword">private</span> String url;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@Pattern</span>(regexp = <span class="string">"^1[3|4|5|7|8][0-9]{9}$"</span>, message = <span class="string">"正则校验是否为正确的手机号"</span>)</span><br><span class="line"> <span class="keyword">private</span> String phone;</span><br><span class="line"></span><br><span class="line"> <span class="comment">// 对关联对象元素进行递归校验检查</span></span><br><span class="line"></span><br><span class="line"> <span class="meta">@Valid</span></span><br><span class="line"> <span class="meta">@UniqueElements</span>(message = <span class="string">"校验集合中的元素是否唯一"</span>)</span><br><span class="line"> <span class="keyword">private</span> List<CalendarEvent> calendarEvent;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@Data</span></span><br><span class="line"> <span class="meta">@ScriptAssert</span>(lang = <span class="string">"javascript"</span>, script = <span class="string">"_this.startDate.before(_this.endDate)"</span>,</span><br><span class="line"> message = <span class="string">"通过脚本表达式校验参数"</span>)</span><br><span class="line"> <span class="keyword">private</span> <span class="class"><span class="keyword">class</span> <span class="title">CalendarEvent</span> </span>{</span><br><span class="line"></span><br><span class="line"> <span class="keyword">private</span> Date startDate;</span><br><span class="line"></span><br><span class="line"> <span class="keyword">private</span> Date endDate;</span><br><span class="line"></span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> <span class="comment">// 数值检查: @Min、@Max、@Range、@DecimalMin、@DecimalMax、@Digits</span></span><br><span class="line"></span><br><span class="line"> <span class="meta">@Min</span>(value = <span class="number">0</span>, message = <span class="string">"验证数值是否大于等于指定值"</span>)</span><br><span class="line"> <span class="meta">@Max</span>(value = <span class="number">100</span>, message = <span class="string">"验证数值是否小于等于指定值"</span>)</span><br><span class="line"> <span class="meta">@Range</span>(min = <span class="number">0</span>, max = <span class="number">100</span>, message = <span class="string">"验证数值是否在指定值区间范围内"</span>)</span><br><span class="line"> <span class="keyword">private</span> Integer score;</span><br><span class="line"></span><br><span class="line"> <span class="meta">@DecimalMin</span>(value = <span class="string">"10.01"</span>, inclusive = <span class="keyword">false</span>, message = <span class="string">"验证数值是否大于等于指定值"</span>)</span><br><span class="line"> <span class="meta">@DecimalMax</span>(value = <span class="string">"199.99"</span>, message = <span class="string">"验证数值是否小于等于指定值"</span>)</span><br><span class="line"> <span class="meta">@Digits</span>(integer = <span class="number">3</span>, fraction = <span class="number">2</span>, message = <span class="string">"限制整数位最多为3,小数位最多为2"</span>)</span><br><span class="line"> <span class="keyword">private</span> BigDecimal money;</span><br><span class="line"></span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>常见的前后端分离开发模式,数据通信通常以 JSON 为主。针对 POST 和 PUT 请求,一般通过新建域(对象)模型来进行数据绑定和校验,constraint 通常附加在这些域模型的字段上(如上):</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Valid注解标明要对参数对象进行数据校验</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"> <span class="meta">@PutMapping</span></span><br><span class="line"> <span class="meta">@PostMapping</span></span><br><span class="line"> <span class="function"><span class="keyword">public</span> Map<String, Object> <span class="title">test01</span><span class="params">(@RequestBody @Valid Validate validate, BindingResult bindingResult)</span> </span>{</span><br><span class="line"> Map<String, Object> map = <span class="keyword">new</span> HashMap<>(<span class="number">4</span>);</span><br><span class="line"></span><br><span class="line"> <span class="keyword">if</span> (bindingResult.hasErrors()) {</span><br><span class="line"> String errorMsg = bindingResult.getFieldErrors().stream().map(FieldError::getDefaultMessage)</span><br><span class="line"> .collect(Collectors.joining(<span class="string">","</span>));</span><br><span class="line"> map.put(<span class="string">"errorMsg"</span>, errorMsg);</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> map.put(<span class="string">"params"</span>, validate.toString());</span><br><span class="line"> <span class="keyword">return</span> map;</span><br><span class="line"> }</span><br></pre></td></tr></table></figure>
<p>此外,对于 GET 和 DELETE 请求,参数通常为 <code>key1=value1&key2=value2</code> 这种形式。默认情况下,Hibernate Validator 只能对 Object 属性进行校验,并不能对单个参数进行校验,Spring 在此基础上进行了扩展,通过配置 MethodValidationPostProcessor 处理器,可以实现对方法参数的拦截校验。</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@Configuration</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ValidateConfig</span> </span>{</span><br><span class="line"></span><br><span class="line"> <span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 配置MethodValidationPostProcessor拦截器,以实现对方法参数的校验</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"> <span class="meta">@Bean</span></span><br><span class="line"> <span class="function"><span class="keyword">public</span> MethodValidationPostProcessor <span class="title">methodValidationPostProcessor</span><span class="params">()</span> </span>{</span><br><span class="line"> <span class="keyword">return</span> <span class="keyword">new</span> MethodValidationPostProcessor();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>注意,要在 Controller 类上明确标明 <code>@Validated</code>:</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@Validated</span></span><br><span class="line"><span class="meta">@RestController</span></span><br><span class="line"><span class="meta">@RequestMapping</span>(<span class="string">"validate"</span>)</span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ValidateController</span> </span>{</span><br><span class="line"></span><br><span class="line"> <span class="meta">@GetMapping</span></span><br><span class="line"> <span class="meta">@DeleteMapping</span></span><br><span class="line"> <span class="function"><span class="keyword">public</span> Map<String, Object> <span class="title">test02</span><span class="params">(@NotNull(message = <span class="string">"id不能为空"</span>)</span> @<span class="title">Range</span><span class="params">(min = <span class="number">1</span>, max = <span class="number">100</span>, message = <span class="string">"id最小为1最大为100"</span>)</span> Integer id,</span></span><br><span class="line"><span class="function"> @<span class="title">NotBlank</span><span class="params">(message = <span class="string">"email不能为空"</span>)</span> @<span class="title">Email</span><span class="params">(message = <span class="string">"邮箱格式错误"</span>)</span> String email,</span></span><br><span class="line"><span class="function"> @ModelAttribute @Valid Validate validate) </span>{</span><br><span class="line"> Map<String, Object> map = <span class="keyword">new</span> HashMap<>(<span class="number">4</span>);</span><br><span class="line"></span><br><span class="line"> map.put(<span class="string">"id"</span>, id);</span><br><span class="line"> map.put(<span class="string">"email"</span>, email);</span><br><span class="line"> map.put(<span class="string">"params"</span>, validate.toString());</span><br><span class="line"></span><br><span class="line"> <span class="keyword">return</span> map;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>上述这种形式的参数要是校验失败,错误提示明显并不友好,通过捕获此类异常就可以解决,这里就不再介绍了。</p>
<h3 id="参考链接"><a href="#参考链接" class="headerlink" title="参考链接"></a>参考链接</h3><blockquote>
<p><a href="https://www.ibm.com/developerworks/cn/java/j-lo-jsr303/index.html" target="_blank" rel="noopener">JSR 303 - Bean Validation 介绍及最佳实践</a><br><a href="https://yezhwi.github.io/springboot/2017/11/17/SpringBoot-%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%8F%82%E6%95%B0%E9%AA%8C%E8%AF%81-JSR-303%E9%AA%8C%E8%AF%81%E6%A1%86%E6%9E%B6/" target="_blank" rel="noopener">SpringBoot-服务端参数验证-JSR-303验证框架</a> </p>
<p><a href="https://github.com/happyjared/spring-boot-learning/tree/master/spring-boot-validation" target="_blank" rel="noopener">示例源码</a><br>欢迎关注我的个人公众号:超级码里奥<br>如果这对您有帮助,欢迎点赞和分享,转载请注明出处 </p>
</blockquote>
<div class="post-copyright">
<div class="content">
<p>最后更新: 2019年06月02日 19:41</p>
<p>原始链接: <a class="post-url" href="/java-parameter-and-bean-validation.html" title="Spring Boot 项目参数校验的常见使用场景">https://blog.mariojd.cn/java-parameter-and-bean-validation.html</a></p>
<footer>
<a href="https://blog.mariojd.cn">
<img src="/images/logo.png" alt="happyJared">
happyJared
</a>
</footer>
</div>
</div>
<div class="page-reward">
<a id="rewardBtn" href="javascript:;">赏</a>
</div>
<div id="reward" class="post-modal reward-lay">
<a class="close" href="javascript:;" id="reward-close">×</a>
<span class="reward-title">
<i class="icon icon-quote-left"></i>
支持创作
<i class="icon icon-quote-right"></i>
</span>
<div class="reward-content">
<div class="reward-code">
<img id="rewardCode" src="/images/wechat_code.jpg" alt="打赏二维码">
</div>
<div class="reward-select">
<label class="reward-select-item checked" data-id="wechat" data-wechat="/images/wechat_code.jpg">
<img class="reward-select-item-wechat" src="/images/wechat.png" alt="微信">
</label>
<label class="reward-select-item" data-id="alipay" data-alipay="/images/alipay_code.jpg">
<img class="reward-select-item-alipay" src="/images/alipay.png" alt="支付宝">
</label>
</div>
</div>
</div>
</div>
<footer class="article-footer">
<div class="post-share">
<a href="javascript:;" id="share-sub" class="post-share-fab">
<i class="fa fa-share-alt"></i>
</a>
<div class="post-share-list" id="share-list">
<ul class="share-icons">
<li>
<a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://blog.mariojd.cn/java-parameter-and-bean-validation.html&title=《Spring Boot 项目参数校验的常见使用场景》 — happyJared - 博客&pic=https://image.mariojd.cn/happyjared/2019115/jsr303-practice-in-java-parameter-and-bean-validation.jpg" data-title="微博">
<i class="fa fa-weibo"></i>
</a>
</li>
<li>
<a class="weixin share-sns" id="wxFab" href="javascript:;" data-title="微信">
<i class="fa fa-weixin"></i>
</a>
</li>
<li>
<a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://blog.mariojd.cn/java-parameter-and-bean-validation.html&title=《Spring Boot 项目参数校验的常见使用场景》 — happyJared - 博客&source=Java developer, like Python and Javascript too,为人乐观、积极、向上、勤奋、和善、好相处,讲卫生,爱学习,爱..." data-title="QQ">
<i class="fa fa-qq"></i>
</a>
</li>
<li>
<a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://blog.mariojd.cn/java-parameter-and-bean-validation.html" data-title="Facebook">
<i class="fa fa-facebook"></i>
</a>
</li>
<li>
<a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Spring Boot 项目参数校验的常见使用场景》 — happyJared - 博客&url=https://blog.mariojd.cn/java-parameter-and-bean-validation.html&via=https://blog.mariojd.cn" data-title="Twitter">
<i class="fa fa-twitter"></i>
</a>
</li>
<li>
<a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://blog.mariojd.cn/java-parameter-and-bean-validation.html" data-title="Google+">
<i class="fa fa-google-plus"></i>
</a>
</li>
</ul>
</div>
</div>
<div class="post-modal wx-share" id="wxShare">
<a class="close" href="javascript:;" id="wxShare-close">×</a>
<p>扫一扫,分享到微信</p>
<img src="//api.qrserver.com/v1/create-qr-code/?data=https://blog.mariojd.cn/java-parameter-and-bean-validation.html" alt="微信分享二维码">
</div>
<div class="mask"></div>
<ul class="article-footer-menu">
<li class="article-footer-tags">
<i class="fa fa-tags"></i>
<a href="/tags/SpringBoot/" class="color2">Spring Boot</a>
<a href="/tags/JSR303/" class="color3">JSR 303</a>
</li>
</ul>
</footer>
</div>
</article>
<aside class="post-toc-pos post-toc-top" id="post-toc">
<nav class="post-toc-wrap">
<ol class="post-toc"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#参考链接"><span class="post-toc-text">参考链接</span></a></li></ol>
</nav>
</aside>
<nav id="article-nav">
<a href="/build-python-program-with-py2exe-or-pyinstaller.html" id="article-nav-newer" class="article-nav-link-wrap">
<span class="article-nav-title">
<i class="fa fa-hand-o-left" aria-hidden="true"></i>
Python 程序打包工具:py2exe 和 PyInstaller
</span>
</a>
<a href="/build-mongo-and-mongo-express-environment-under-docker.html" id="article-nav-older" class="article-nav-link-wrap">
<span class="article-nav-title">Docker 下的 MongoDB + Mongo-Express 环境搭建</span>
<i class="fa fa-hand-o-right" aria-hidden="true"></i>
</a>
</nav>
<div id="SOHUCS" sid="Java 服务端参数校验 - JSR 303介绍及实践" ></div>
<script type="text/javascript">
(function(){
var appid = 'cytsi4W0L';
var conf = 'prod_302a63175740fd2ee2587f9345477b4c';
var width = window.innerWidth || document.documentElement.clientWidth;
if (width < 960) {
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})}); } })(); </script>
</section>
</div>
<footer id="footer">
<div class="outer">
<div id="footer-info" class="inner">
<p>
<span id="busuanzi_container_site_uv" style='display:none'>
访客数:<span id="busuanzi_value_site_uv"></span>
</span>
<span id="busuanzi_container_site_pv" style='display:none'>
访问量:<span id="busuanzi_value_site_pv"></span>
</span>
<span style='margin-left:5px'>
粤ICP备17033077号-1
</span>
</p>
<p>
<!-- Powered by <a href="http://hexo.io/" target="_blank">Hexo</a> -->
<!-- Theme <a href="//github.com/wongminho/hexo-theme-miho" target="_blank">MiHo</a> -->
Copyright © 2018 - 2020 happyJared
<!-- Hosted by <a href="https://pages.coding.me" style="font-weight: bold">Coding Pages</a> -->
<script type="text/javascript" src="//js.users.51.la/19683707.js"></script>
<!-- <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1274993267'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s19.cnzz.com/z_stat.php%3Fid%3D1274993267%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));</script> -->
<br>
</p>
</div>
</div>
</footer>
<script>
(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>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script src="https://v1.hitokoto.cn/?encode=js&select=%23hitokoto" defer></script>
<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script>
var mihoConfig = {
root: "https://blog.mariojd.cn",
animate: false,
isHome: false,
share: true,
reward: 1
}
</script>
<div class="sidebar">
<div id="sidebar-search" title="Search">
<i class="fa fa-search"></i>
</div>
<div id="sidebar-category" title="Categories">
<i class="fa fa-book"></i>
</div>
<div id="sidebar-tag" title="Tags">
<i class="fa fa-tags"></i>
</div>
<div id="sidebar-top">
<span class="sidebar-top-icon"><i class="fa fa-angle-up"></i></span>
</div>
</div>
<div class="sidebar-menu-box" id="sidebar-menu-box">
<div class="sidebar-menu-box-container">
<div id="sidebar-menu-box-categories">
<a class="category-link" href="/categories/Chocolatey/">Chocolatey</a><a class="category-link" href="/categories/Docker/">Docker</a><a class="category-link" href="/categories/Docker/Elasticsearch/">Elasticsearch</a><a class="category-link" href="/categories/Docker/MySQL/">MySQL</a><a class="category-link" href="/categories/Docker/PostgreSQL/">PostgreSQL</a><a class="category-link" href="/categories/Docker/Redis/">Redis</a><a class="category-link" href="/categories/IDEA/">IDEA</a><a class="category-link" href="/categories/Java/">Java</a><a class="category-link" href="/categories/Java/Lombok/">Lombok</a><a class="category-link" href="/categories/Java/Spring-Boot/">Spring Boot</a><a class="category-link" href="/categories/Java/Spring-Boot/Swagger/">Swagger</a><a class="category-link" href="/categories/Java/热部署/">热部署</a><a class="category-link" href="/categories/Jmeter/">Jmeter</a><a class="category-link" href="/categories/Linux/">Linux</a><a class="category-link" href="/categories/Micro-Service/">Micro Service</a><a class="category-link" href="/categories/Python/">Python</a><a class="category-link" href="/categories/Python/Selenium/">Selenium</a><a class="category-link" href="/categories/Python/Selenium/Windows-Batch/">Windows Batch</a><a class="category-link" href="/categories/Redis/">Redis</a><a class="category-link" href="/categories/Spring/">Spring</a><a class="category-link" href="/categories/Web/">Web</a><a class="category-link" href="/categories/hexo/">hexo</a><a class="category-link" href="/categories/python/">python</a><a class="category-link" href="/categories/websocket/">websocket</a><a class="category-link" href="/categories/中间件/">中间件</a><a class="category-link" href="/categories/前端/">前端</a><a class="category-link" href="/categories/学习资源/">学习资源</a><a class="category-link" href="/categories/开源/">开源</a><a class="category-link" href="/categories/开源/YApi/">YApi</a><a class="category-link" href="/categories/开源/YApi/Swagger/">Swagger</a><a class="category-link" href="/categories/开源和中间件/">开源和中间件</a><a class="category-link" href="/categories/开源项目/">开源项目</a><a class="category-link" href="/categories/抓包工具/">抓包工具</a><a class="category-link" href="/categories/数据库中间件/">数据库中间件</a><a class="category-link" href="/categories/数据库中间件/Mycat/">Mycat</a><a class="category-link" href="/categories/编辑器/">编辑器</a><a class="category-link" href="/categories/编辑器/个人感悟/">个人感悟</a><a class="category-link" href="/categories/编辑器/快捷键/">快捷键</a><a class="category-link" href="/categories/设计模式/">设计模式</a><a class="category-link" href="/categories/随笔/">随笔</a>
</div>
<div id="sidebar-menu-box-tags">
<a href="/tags/AcpectJ/" style="font-size: 10px;">AcpectJ</a> <a href="/tags/Aop/" style="font-size: 10px;">Aop</a> <a href="/tags/Chocolatey/" style="font-size: 10px;">Chocolatey</a> <a href="/tags/Config-Center/" style="font-size: 10.91px;">Config Center</a> <a href="/tags/Ctrip-Apollo/" style="font-size: 10.91px;">Ctrip Apollo</a> <a href="/tags/Eclipse/" style="font-size: 10.91px;">Eclipse</a> <a href="/tags/Faker/" style="font-size: 10.91px;">Faker</a> <a href="/tags/Fiddler/" style="font-size: 10px;">Fiddler</a> <a href="/tags/GitHub-Pages/" style="font-size: 10.91px;">GitHub Pages</a> <a href="/tags/Hexo/" style="font-size: 10px;">Hexo</a> <a href="/tags/IDEA/" style="font-size: 20px;">IDEA</a> <a href="/tags/JSR-303/" style="font-size: 10px;">JSR 303</a> <a href="/tags/Java/" style="font-size: 16.36px;">Java</a> <a href="/tags/Java类库/" style="font-size: 10px;">Java类库</a> <a href="/tags/JetBrains/" style="font-size: 18.18px;">JetBrains</a> <a href="/tags/Jmeter/" style="font-size: 11.82px;">Jmeter</a> <a href="/tags/Lombok/" style="font-size: 10px;">Lombok</a> <a href="/tags/Micro-Service/" style="font-size: 10.91px;">Micro Service</a> <a href="/tags/Mycat/" style="font-size: 12.73px;">Mycat</a> <a href="/tags/ORM/" style="font-size: 10.91px;">ORM</a> <a href="/tags/Peewee/" style="font-size: 10px;">Peewee</a> <a href="/tags/Python/" style="font-size: 11.82px;">Python</a> <a href="/tags/RestTemplate/" style="font-size: 10px;">RestTemplate</a> <a href="/tags/SQLAlchemy/" style="font-size: 10px;">SQLAlchemy</a> <a href="/tags/Spring/" style="font-size: 10.91px;">Spring</a> <a href="/tags/Spring-Boot/" style="font-size: 13.64px;">Spring Boot</a> <a href="/tags/Spring-Data-Elasticsearch/" style="font-size: 10px;">Spring Data Elasticsearch</a> <a href="/tags/Spring-in-action/" style="font-size: 10px;">Spring in action</a> <a href="/tags/Windows/" style="font-size: 10px;">Windows</a> <a href="/tags/ajax/" style="font-size: 10px;">ajax</a> <a href="/tags/appium/" style="font-size: 10px;">appium</a> <a href="/tags/base-command/" style="font-size: 10px;">base command</a> <a href="/tags/bash/" style="font-size: 10px;">bash</a> <a href="/tags/bat/" style="font-size: 10px;">bat</a> <a href="/tags/bat脚本/" style="font-size: 10px;">bat脚本</a> <a href="/tags/beautifulsoup4/" style="font-size: 10px;">beautifulsoup4</a> <a href="/tags/boss/" style="font-size: 10px;">boss</a> <a href="/tags/builder/" style="font-size: 10px;">builder</a> <a href="/tags/chrome/" style="font-size: 10.91px;">chrome</a> <a href="/tags/chrome-plugin/" style="font-size: 10px;">chrome plugin</a> <a href="/tags/coding-net/" style="font-size: 10px;">coding.net</a> <a href="/tags/common-commands/" style="font-size: 10.91px;">common commands</a> <a href="/tags/csdn/" style="font-size: 10px;">csdn</a> <a href="/tags/design-patterns/" style="font-size: 14.55px;">design patterns</a> <a href="/tags/directory-management/" style="font-size: 10px;">directory management</a> <a href="/tags/directory-permission/" style="font-size: 10px;">directory permission</a> <a href="/tags/disk-management/" style="font-size: 10px;">disk management</a> <a href="/tags/docker/" style="font-size: 15.45px;">docker</a> <a href="/tags/docker-compose/" style="font-size: 10px;">docker compose</a> <a href="/tags/druid/" style="font-size: 10px;">druid</a> <a href="/tags/elasticsearch/" style="font-size: 10.91px;">elasticsearch</a> <a href="/tags/elasticsearch-cluster/" style="font-size: 10px;">elasticsearch cluster</a> <a href="/tags/ffmpeg/" style="font-size: 10px;">ffmpeg</a> <a href="/tags/fiddler/" style="font-size: 10px;">fiddler</a> <a href="/tags/fiddler-capture/" style="font-size: 10px;">fiddler capture</a> <a href="/tags/file-management/" style="font-size: 10px;">file management</a> <a href="/tags/file-permission/" style="font-size: 10px;">file permission</a> <a href="/tags/head-plugin/" style="font-size: 10px;">head plugin</a> <a href="/tags/hexo/" style="font-size: 13.64px;">hexo</a> <a href="/tags/hexo-themes/" style="font-size: 10px;">hexo themes</a> <a href="/tags/hexo-translate-title/" style="font-size: 10px;">hexo-translate-title</a> <a href="/tags/hot-key/" style="font-size: 10px;">hot key</a> <a href="/tags/http/" style="font-size: 10px;">http</a> <a href="/tags/http-proxy/" style="font-size: 10px;">http proxy</a> <a href="/tags/http-s/" style="font-size: 10px;">http(s)</a> <a href="/tags/https/" style="font-size: 10px;">https</a> <a href="/tags/https抓包/" style="font-size: 10px;">https抓包</a> <a href="/tags/ik-analysis/" style="font-size: 10px;">ik analysis</a> <a href="/tags/imooc/" style="font-size: 10px;">imooc</a> <a href="/tags/itchat/" style="font-size: 10px;">itchat</a> <a href="/tags/jasypt-spring-boot/" style="font-size: 10px;">jasypt spring boot</a> <a href="/tags/java/" style="font-size: 10.91px;">java</a> <a href="/tags/java-error/" style="font-size: 10px;">java error</a> <a href="/tags/java-exception/" style="font-size: 10px;">java exception</a> <a href="/tags/java8-stream/" style="font-size: 10px;">java8 stream</a> <a href="/tags/javacv/" style="font-size: 10px;">javacv</a> <a href="/tags/jetcache/" style="font-size: 10px;">jetcache</a> <a href="/tags/jsonp/" style="font-size: 10px;">jsonp</a> <a href="/tags/jvm/" style="font-size: 10px;">jvm</a> <a href="/tags/lagou/" style="font-size: 10px;">lagou</a> <a href="/tags/linux-backup/" style="font-size: 10px;">linux backup</a> <a href="/tags/linux-compress/" style="font-size: 10px;">linux compress</a> <a href="/tags/linux-packeage/" style="font-size: 10px;">linux packeage</a> <a href="/tags/linux-thing/" style="font-size: 13.64px;">linux thing</a> <a href="/tags/mind-mapping/" style="font-size: 11.82px;">mind mapping</a> <a href="/tags/mitmproxy/" style="font-size: 10px;">mitmproxy</a> <a href="/tags/mongo-express/" style="font-size: 10px;">mongo-express</a> <a href="/tags/mongodb/" style="font-size: 10px;">mongodb</a> <a href="/tags/multiple-datasource/" style="font-size: 10.91px;">multiple datasource</a> <a href="/tags/mybatis/" style="font-size: 10px;">mybatis</a> <a href="/tags/mysql/" style="font-size: 11.82px;">mysql</a> <a href="/tags/nginx/" style="font-size: 10.91px;">nginx</a> <a href="/tags/oschina/" style="font-size: 10px;">oschina</a> <a href="/tags/postgresql/" style="font-size: 11.82px;">postgresql</a> <a href="/tags/prototype/" style="font-size: 10px;">prototype</a> <a href="/tags/py2exe/" style="font-size: 10px;">py2exe</a> <a href="/tags/pyinstaller/" style="font-size: 10px;">pyinstaller</a> <a href="/tags/python/" style="font-size: 17.27px;">python</a> <a href="/tags/python-core/" style="font-size: 10px;">python core</a> <a href="/tags/python-data-science/" style="font-size: 10px;">python data science</a> <a href="/tags/python-spider/" style="font-size: 10px;">python spider</a> <a href="/tags/python-standard-library/" style="font-size: 10px;">python standard library</a> <a href="/tags/redis/" style="font-size: 12.73px;">redis</a> <a href="/tags/redis-sentinel/" style="font-size: 10px;">redis-sentinel</a> <a href="/tags/requests/" style="font-size: 10px;">requests</a> <a href="/tags/restful-api/" style="font-size: 10px;">restful api</a> <a href="/tags/scrapy/" style="font-size: 12.73px;">scrapy</a> <a href="/tags/selenium/" style="font-size: 13.64px;">selenium</a> <a href="/tags/shortcuts-key/" style="font-size: 10px;">shortcuts key</a> <a href="/tags/simple-factory/" style="font-size: 11.82px;">simple factory</a> <a href="/tags/singleton/" style="font-size: 10px;">singleton</a> <a href="/tags/spider/" style="font-size: 10.91px;">spider</a> <a href="/tags/spider-crawl/" style="font-size: 10px;">spider crawl</a> <a href="/tags/spring-boot/" style="font-size: 17.27px;">spring boot</a> <a href="/tags/spring-boot-actuator/" style="font-size: 10px;">spring boot actuator</a> <a href="/tags/spring-boot-admin/" style="font-size: 10px;">spring boot admin</a> <a href="/tags/spring-boot2/" style="font-size: 10px;">spring boot2</a> <a href="/tags/spring-cache/" style="font-size: 10px;">spring cache</a> <a href="/tags/spring-data-jpa/" style="font-size: 12.73px;">spring data jpa</a> <a href="/tags/spring-data-rest/" style="font-size: 10px;">spring data rest</a> <a href="/tags/swagger/" style="font-size: 10.91px;">swagger</a> <a href="/tags/tomcat/" style="font-size: 10px;">tomcat</a> <a href="/tags/vi/" style="font-size: 10px;">vi</a> <a href="/tags/vim/" style="font-size: 10px;">vim</a> <a href="/tags/vimium/" style="font-size: 10px;">vimium</a> <a href="/tags/websocket/" style="font-size: 10px;">websocket</a> <a href="/tags/weixin/" style="font-size: 10px;">weixin</a> <a href="/tags/ws-s/" style="font-size: 10px;">ws(s)</a> <a href="/tags/wss/" style="font-size: 10px;">wss</a> <a href="/tags/yapi/" style="font-size: 10px;">yapi</a> <a href="/tags/zealer/" style="font-size: 10px;">zealer</a> <a href="/tags/个人博客/" style="font-size: 10.91px;">个人博客</a> <a href="/tags/个人感悟/" style="font-size: 10.91px;">个人感悟</a> <a href="/tags/主从复制/" style="font-size: 10.91px;">主从复制</a> <a href="/tags/主从搭建/" style="font-size: 11.82px;">主从搭建</a> <a href="/tags/乐观锁/" style="font-size: 10px;">乐观锁</a> <a href="/tags/代理调试/" style="font-size: 10px;">代理调试</a> <a href="/tags/入门篇/" style="font-size: 10px;">入门篇</a> <a href="/tags/单例/" style="font-size: 10px;">单例</a> <a href="/tags/博客/" style="font-size: 10px;">博客</a> <a href="/tags/压测工具/" style="font-size: 11.82px;">压测工具</a> <a href="/tags/原型/" style="font-size: 10px;">原型</a> <a href="/tags/字符串机制/" style="font-size: 10px;">字符串机制</a> <a href="/tags/学习资源/" style="font-size: 10.91px;">学习资源</a> <a href="/tags/实践篇/" style="font-size: 10.91px;">实践篇</a> <a href="/tags/工厂方法/" style="font-size: 10px;">工厂方法</a> <a href="/tags/建造者/" style="font-size: 10px;">建造者</a> <a href="/tags/开源/" style="font-size: 10px;">开源</a> <a href="/tags/开源博客/" style="font-size: 10.91px;">开源博客</a> <a href="/tags/开源项目/" style="font-size: 10.91px;">开源项目</a> <a href="/tags/微信授权/" style="font-size: 10px;">微信授权</a> <a href="/tags/悲观锁/" style="font-size: 10px;">悲观锁</a> <a href="/tags/抽象工厂/" style="font-size: 10px;">抽象工厂</a> <a href="/tags/数据库中间件/" style="font-size: 12.73px;">数据库中间件</a> <a href="/tags/热部署/" style="font-size: 10px;">热部署</a> <a href="/tags/简书/" style="font-size: 10px;">简书</a> <a href="/tags/简单工厂/" style="font-size: 10px;">简单工厂</a> <a href="/tags/编辑器/" style="font-size: 19.09px;">编辑器</a> <a href="/tags/读书笔记/" style="font-size: 10px;">读书笔记</a> <a href="/tags/读写分离/" style="font-size: 10.91px;">读写分离</a> <a href="/tags/跑步/" style="font-size: 10px;">跑步</a> <a href="/tags/配置篇/" style="font-size: 10px;">配置篇</a> <a href="/tags/钉钉运动/" style="font-size: 10px;">钉钉运动</a> <a href="/tags/阿里技术/" style="font-size: 10px;">阿里技术</a>
</div>
</div>
<a href="javascript:;" class="sidebar-menu-box-close">×</a>
</div>
<div class="mobile-header-menu-nav" id="mobile-header-menu-nav">
<div class="mobile-header-menu-container">
<span class="title">Menus</span>
<ul class="mobile-header-menu-navbar">
<li>
<a href="/">
<i class="fa fa-h-square"></i><span>主页</span>
</a>
</li>
<li>
<a href="/life">
<i class="fa fa-battery-three-quarters"></i><span>岁月</span>
</a>
</li>
<li>
<a target="_blank" href="https://mp.mariojd.cn">
<i class="fa fa-dot-circle-o"></i><span>洞见</span>
</a>
</li>
<li>
<a href="/archives">
<i class="fa fa-window-restore"></i><span>归档</span>
</a>
</li>
<li>
<a target="_blank" href="http://jianshu.mariojd.cn">
<i class="fa fa-superpowers"></i><span>简统</span>
</a>
</li>
<li>
<a href="/about">
<i class="fa fa-user"></i><span>关于</span>
</a>
</li>
</ul>
</div>
<div class="mobile-header-tag-container">
<span class="title">Tags</span>
<div id="mobile-header-container-tags">
<a href="/tags/AcpectJ/" style="font-size: 10px;">AcpectJ</a> <a href="/tags/Aop/" style="font-size: 10px;">Aop</a> <a href="/tags/Chocolatey/" style="font-size: 10px;">Chocolatey</a> <a href="/tags/Config-Center/" style="font-size: 10.91px;">Config Center</a> <a href="/tags/Ctrip-Apollo/" style="font-size: 10.91px;">Ctrip Apollo</a> <a href="/tags/Eclipse/" style="font-size: 10.91px;">Eclipse</a> <a href="/tags/Faker/" style="font-size: 10.91px;">Faker</a> <a href="/tags/Fiddler/" style="font-size: 10px;">Fiddler</a> <a href="/tags/GitHub-Pages/" style="font-size: 10.91px;">GitHub Pages</a> <a href="/tags/Hexo/" style="font-size: 10px;">Hexo</a> <a href="/tags/IDEA/" style="font-size: 20px;">IDEA</a> <a href="/tags/JSR-303/" style="font-size: 10px;">JSR 303</a> <a href="/tags/Java/" style="font-size: 16.36px;">Java</a> <a href="/tags/Java类库/" style="font-size: 10px;">Java类库</a> <a href="/tags/JetBrains/" style="font-size: 18.18px;">JetBrains</a> <a href="/tags/Jmeter/" style="font-size: 11.82px;">Jmeter</a> <a href="/tags/Lombok/" style="font-size: 10px;">Lombok</a> <a href="/tags/Micro-Service/" style="font-size: 10.91px;">Micro Service</a> <a href="/tags/Mycat/" style="font-size: 12.73px;">Mycat</a> <a href="/tags/ORM/" style="font-size: 10.91px;">ORM</a> <a href="/tags/Peewee/" style="font-size: 10px;">Peewee</a> <a href="/tags/Python/" style="font-size: 11.82px;">Python</a> <a href="/tags/RestTemplate/" style="font-size: 10px;">RestTemplate</a> <a href="/tags/SQLAlchemy/" style="font-size: 10px;">SQLAlchemy</a> <a href="/tags/Spring/" style="font-size: 10.91px;">Spring</a> <a href="/tags/Spring-Boot/" style="font-size: 13.64px;">Spring Boot</a> <a href="/tags/Spring-Data-Elasticsearch/" style="font-size: 10px;">Spring Data Elasticsearch</a> <a href="/tags/Spring-in-action/" style="font-size: 10px;">Spring in action</a> <a href="/tags/Windows/" style="font-size: 10px;">Windows</a> <a href="/tags/ajax/" style="font-size: 10px;">ajax</a> <a href="/tags/appium/" style="font-size: 10px;">appium</a> <a href="/tags/base-command/" style="font-size: 10px;">base command</a> <a href="/tags/bash/" style="font-size: 10px;">bash</a> <a href="/tags/bat/" style="font-size: 10px;">bat</a> <a href="/tags/bat脚本/" style="font-size: 10px;">bat脚本</a> <a href="/tags/beautifulsoup4/" style="font-size: 10px;">beautifulsoup4</a> <a href="/tags/boss/" style="font-size: 10px;">boss</a> <a href="/tags/builder/" style="font-size: 10px;">builder</a> <a href="/tags/chrome/" style="font-size: 10.91px;">chrome</a> <a href="/tags/chrome-plugin/" style="font-size: 10px;">chrome plugin</a> <a href="/tags/coding-net/" style="font-size: 10px;">coding.net</a> <a href="/tags/common-commands/" style="font-size: 10.91px;">common commands</a> <a href="/tags/csdn/" style="font-size: 10px;">csdn</a> <a href="/tags/design-patterns/" style="font-size: 14.55px;">design patterns</a> <a href="/tags/directory-management/" style="font-size: 10px;">directory management</a> <a href="/tags/directory-permission/" style="font-size: 10px;">directory permission</a> <a href="/tags/disk-management/" style="font-size: 10px;">disk management</a> <a href="/tags/docker/" style="font-size: 15.45px;">docker</a> <a href="/tags/docker-compose/" style="font-size: 10px;">docker compose</a> <a href="/tags/druid/" style="font-size: 10px;">druid</a> <a href="/tags/elasticsearch/" style="font-size: 10.91px;">elasticsearch</a> <a href="/tags/elasticsearch-cluster/" style="font-size: 10px;">elasticsearch cluster</a> <a href="/tags/ffmpeg/" style="font-size: 10px;">ffmpeg</a> <a href="/tags/fiddler/" style="font-size: 10px;">fiddler</a> <a href="/tags/fiddler-capture/" style="font-size: 10px;">fiddler capture</a> <a href="/tags/file-management/" style="font-size: 10px;">file management</a> <a href="/tags/file-permission/" style="font-size: 10px;">file permission</a> <a href="/tags/head-plugin/" style="font-size: 10px;">head plugin</a> <a href="/tags/hexo/" style="font-size: 13.64px;">hexo</a> <a href="/tags/hexo-themes/" style="font-size: 10px;">hexo themes</a> <a href="/tags/hexo-translate-title/" style="font-size: 10px;">hexo-translate-title</a> <a href="/tags/hot-key/" style="font-size: 10px;">hot key</a> <a href="/tags/http/" style="font-size: 10px;">http</a> <a href="/tags/http-proxy/" style="font-size: 10px;">http proxy</a> <a href="/tags/http-s/" style="font-size: 10px;">http(s)</a> <a href="/tags/https/" style="font-size: 10px;">https</a> <a href="/tags/https抓包/" style="font-size: 10px;">https抓包</a> <a href="/tags/ik-analysis/" style="font-size: 10px;">ik analysis</a> <a href="/tags/imooc/" style="font-size: 10px;">imooc</a> <a href="/tags/itchat/" style="font-size: 10px;">itchat</a> <a href="/tags/jasypt-spring-boot/" style="font-size: 10px;">jasypt spring boot</a> <a href="/tags/java/" style="font-size: 10.91px;">java</a> <a href="/tags/java-error/" style="font-size: 10px;">java error</a> <a href="/tags/java-exception/" style="font-size: 10px;">java exception</a> <a href="/tags/java8-stream/" style="font-size: 10px;">java8 stream</a> <a href="/tags/javacv/" style="font-size: 10px;">javacv</a> <a href="/tags/jetcache/" style="font-size: 10px;">jetcache</a> <a href="/tags/jsonp/" style="font-size: 10px;">jsonp</a> <a href="/tags/jvm/" style="font-size: 10px;">jvm</a> <a href="/tags/lagou/" style="font-size: 10px;">lagou</a> <a href="/tags/linux-backup/" style="font-size: 10px;">linux backup</a> <a href="/tags/linux-compress/" style="font-size: 10px;">linux compress</a> <a href="/tags/linux-packeage/" style="font-size: 10px;">linux packeage</a> <a href="/tags/linux-thing/" style="font-size: 13.64px;">linux thing</a> <a href="/tags/mind-mapping/" style="font-size: 11.82px;">mind mapping</a> <a href="/tags/mitmproxy/" style="font-size: 10px;">mitmproxy</a> <a href="/tags/mongo-express/" style="font-size: 10px;">mongo-express</a> <a href="/tags/mongodb/" style="font-size: 10px;">mongodb</a> <a href="/tags/multiple-datasource/" style="font-size: 10.91px;">multiple datasource</a> <a href="/tags/mybatis/" style="font-size: 10px;">mybatis</a> <a href="/tags/mysql/" style="font-size: 11.82px;">mysql</a> <a href="/tags/nginx/" style="font-size: 10.91px;">nginx</a> <a href="/tags/oschina/" style="font-size: 10px;">oschina</a> <a href="/tags/postgresql/" style="font-size: 11.82px;">postgresql</a> <a href="/tags/prototype/" style="font-size: 10px;">prototype</a> <a href="/tags/py2exe/" style="font-size: 10px;">py2exe</a> <a href="/tags/pyinstaller/" style="font-size: 10px;">pyinstaller</a> <a href="/tags/python/" style="font-size: 17.27px;">python</a> <a href="/tags/python-core/" style="font-size: 10px;">python core</a> <a href="/tags/python-data-science/" style="font-size: 10px;">python data science</a> <a href="/tags/python-spider/" style="font-size: 10px;">python spider</a> <a href="/tags/python-standard-library/" style="font-size: 10px;">python standard library</a> <a href="/tags/redis/" style="font-size: 12.73px;">redis</a> <a href="/tags/redis-sentinel/" style="font-size: 10px;">redis-sentinel</a> <a href="/tags/requests/" style="font-size: 10px;">requests</a> <a href="/tags/restful-api/" style="font-size: 10px;">restful api</a> <a href="/tags/scrapy/" style="font-size: 12.73px;">scrapy</a> <a href="/tags/selenium/" style="font-size: 13.64px;">selenium</a> <a href="/tags/shortcuts-key/" style="font-size: 10px;">shortcuts key</a> <a href="/tags/simple-factory/" style="font-size: 11.82px;">simple factory</a> <a href="/tags/singleton/" style="font-size: 10px;">singleton</a> <a href="/tags/spider/" style="font-size: 10.91px;">spider</a> <a href="/tags/spider-crawl/" style="font-size: 10px;">spider crawl</a> <a href="/tags/spring-boot/" style="font-size: 17.27px;">spring boot</a> <a href="/tags/spring-boot-actuator/" style="font-size: 10px;">spring boot actuator</a> <a href="/tags/spring-boot-admin/" style="font-size: 10px;">spring boot admin</a> <a href="/tags/spring-boot2/" style="font-size: 10px;">spring boot2</a> <a href="/tags/spring-cache/" style="font-size: 10px;">spring cache</a> <a href="/tags/spring-data-jpa/" style="font-size: 12.73px;">spring data jpa</a> <a href="/tags/spring-data-rest/" style="font-size: 10px;">spring data rest</a> <a href="/tags/swagger/" style="font-size: 10.91px;">swagger</a> <a href="/tags/tomcat/" style="font-size: 10px;">tomcat</a> <a href="/tags/vi/" style="font-size: 10px;">vi</a> <a href="/tags/vim/" style="font-size: 10px;">vim</a> <a href="/tags/vimium/" style="font-size: 10px;">vimium</a> <a href="/tags/websocket/" style="font-size: 10px;">websocket</a> <a href="/tags/weixin/" style="font-size: 10px;">weixin</a> <a href="/tags/ws-s/" style="font-size: 10px;">ws(s)</a> <a href="/tags/wss/" style="font-size: 10px;">wss</a> <a href="/tags/yapi/" style="font-size: 10px;">yapi</a> <a href="/tags/zealer/" style="font-size: 10px;">zealer</a> <a href="/tags/个人博客/" style="font-size: 10.91px;">个人博客</a> <a href="/tags/个人感悟/" style="font-size: 10.91px;">个人感悟</a> <a href="/tags/主从复制/" style="font-size: 10.91px;">主从复制</a> <a href="/tags/主从搭建/" style="font-size: 11.82px;">主从搭建</a> <a href="/tags/乐观锁/" style="font-size: 10px;">乐观锁</a> <a href="/tags/代理调试/" style="font-size: 10px;">代理调试</a> <a href="/tags/入门篇/" style="font-size: 10px;">入门篇</a> <a href="/tags/单例/" style="font-size: 10px;">单例</a> <a href="/tags/博客/" style="font-size: 10px;">博客</a> <a href="/tags/压测工具/" style="font-size: 11.82px;">压测工具</a> <a href="/tags/原型/" style="font-size: 10px;">原型</a> <a href="/tags/字符串机制/" style="font-size: 10px;">字符串机制</a> <a href="/tags/学习资源/" style="font-size: 10.91px;">学习资源</a> <a href="/tags/实践篇/" style="font-size: 10.91px;">实践篇</a> <a href="/tags/工厂方法/" style="font-size: 10px;">工厂方法</a> <a href="/tags/建造者/" style="font-size: 10px;">建造者</a> <a href="/tags/开源/" style="font-size: 10px;">开源</a> <a href="/tags/开源博客/" style="font-size: 10.91px;">开源博客</a> <a href="/tags/开源项目/" style="font-size: 10.91px;">开源项目</a> <a href="/tags/微信授权/" style="font-size: 10px;">微信授权</a> <a href="/tags/悲观锁/" style="font-size: 10px;">悲观锁</a> <a href="/tags/抽象工厂/" style="font-size: 10px;">抽象工厂</a> <a href="/tags/数据库中间件/" style="font-size: 12.73px;">数据库中间件</a> <a href="/tags/热部署/" style="font-size: 10px;">热部署</a> <a href="/tags/简书/" style="font-size: 10px;">简书</a> <a href="/tags/简单工厂/" style="font-size: 10px;">简单工厂</a> <a href="/tags/编辑器/" style="font-size: 19.09px;">编辑器</a> <a href="/tags/读书笔记/" style="font-size: 10px;">读书笔记</a> <a href="/tags/读写分离/" style="font-size: 10.91px;">读写分离</a> <a href="/tags/跑步/" style="font-size: 10px;">跑步</a> <a href="/tags/配置篇/" style="font-size: 10px;">配置篇</a> <a href="/tags/钉钉运动/" style="font-size: 10px;">钉钉运动</a> <a href="/tags/阿里技术/" style="font-size: 10px;">阿里技术</a>
</div>
</div>
</div>
<div class="search-wrap">
<span class="search-close">×</span>
<a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
<i class="icon icon-lg icon-chevron-left"></i>
</a>
<input class="search-field" placeholder="Search..." id="keywords">
<a id="search-submit" href="javascript:;">
<i class="fa fa-search"></i>
</a>
<div class="search-container" id="search-container">
<ul class="search-result" id="search-result">
</ul>
</div>
</div>
<div id="search-tpl">
<li class="search-result-item">
<a href="{url}" class="search-item-li">
<span class="search-item-li-title" title="{title}">{title}</span>
</a>
</li>
</div>
<script src="/js/search.js"></script>
<script src="/js/main.js"></script>
<script src="//cdn.bootcss.com/particles.js/2.0.0/particles.min.js"></script>
<div id="particles"></div>
<script src="/js/particles.js"></script>
<script src="/js/pop-img.js"></script>
<script>
$(".article-entry p img").popImg();
</script>
</div>
</body>
</html>