-
Notifications
You must be signed in to change notification settings - Fork 0
/
SSM.html
1352 lines (739 loc) · 126 KB
/
SSM.html
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
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head hexo-theme='https://volantis.js.org/#2.1.2'>
<meta charset="utf-8">
<!-- SEO相关 -->
<!-- 渲染优化 -->
<meta name="renderer" content="webkit">
<meta name="force-rendering" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="HandheldFriendly" content="True" >
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- 页面元数据 -->
<title>Maven下的SSM整合 - CRainyDay</title>
<meta name="keywords" content="Spring,SpringMVC,MyBatis,Maven">
<meta name="description" content="在Eclipse下使用Maven创建和管理SSM项目.">
<!-- feed -->
<!-- import meta -->
<!-- link -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/[email protected]/dist/jquery.fancybox.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/waves.min.css">
<link rel="shortcut icon" type='image/x-icon' href="https://cdn.jsdelivr.net/gh/crainyday/blog@master/favicon.ico">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/APlayer.min.css">
<!-- import link -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/crainyday/blog@master/css/style.css">
<script>
function setLoadingBarProgress(num) {
document.getElementById('loading-bar').style.width=num+"%";
}
</script>
<!-- ba -->
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?bf368df5385d5be3472f3155e4cdb303";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</head>
<body>
<div id="loading-bar-wrapper">
<div id="loading-bar"></div>
</div>
<header class="l_header shadow floatable blur">
<div class='wrapper'>
<div class='nav-sub container--flex'>
<a class="logo flat-box"></a>
<ul class='switcher h-list'>
<li><a class="s-comment flat-btn fas fa-comments fa-fw" target="_self" href='javascript:void(0)'></a></li>
<li><a class="s-toc flat-btn fas fa-list fa-fw" target="_self" href='javascript:void(0)'></a></li>
</ul>
</div>
<div class="nav-main container container--flex">
<a class="logo flat-box" target="_self" href='/'>
<i class='fas fa-home'></i>
CRainyDay
</a>
<div class='menu navigation'>
<ul class='h-list'>
<li>
<a class="flat-box" href=/categories/
id="categories"
>
<i class='fas fa-folder-open fa-fw'></i>
分类
</a>
</li>
<li>
<a class="flat-box" href=/archives/
id="archives"
>
<i class='fas fa-archive fa-fw'></i>
归档
</a>
</li>
<li>
<a class="flat-box" href=/tags/
id="tags"
>
<i class='fas fa-tags fa-fw'></i>
标签
</a>
</li>
<li>
<a class="flat-box" href=/friends/
id="friends"
>
<i class='fas fa-link fa-fw'></i>
友链
</a>
</li>
<li>
<a class="flat-box"
>
<i class='fas fa-ellipsis-v fa-fw'></i>
更多
</a>
<ul class="submenu">
<li>
<a class="flat-box" href=/about/music.html
id="aboutmusic.html"
>
<i class='fas fa-music fa-fw'></i>
往后余生
</a>
</li>
<hr>
<li>
<a class="flat-box" href=/bbs/
id="bbs"
>
<i class='fas fa-comment-alt fa-fw'></i>
留言
</a>
</li>
<hr>
<li>
<a class="flat-box" href=/about/
id="about"
>
<i class='fas fa-info-circle fa-fw'></i>
关于
</a>
</li>
</ul>
</li>
</ul>
</div>
<div class="m_search">
<form name="searchform" class="form u-search-form">
<i class="icon fas fa-search fa-fw"></i>
<input type="text" class="input u-search-input" placeholder="搜索" />
</form>
</div>
<ul class='switcher h-list'>
<li><a class="s-search flat-btn fas fa-search fa-fw" target="_self" href='javascript:void(0)'></a></li>
<li><a class="s-menu flat-btn fas fa-bars fa-fw" target="_self" href='javascript:void(0)'></a></li>
</ul>
</div>
</div>
</header>
<ul class="menu-phone navigation white-box">
<li>
<a class="flat-box" href=/
id="home"
>
<i class='fas fa-home fa-fw'></i>
博客
</a>
</li>
<li>
<a class="flat-box" href=/archives/
id="archives"
>
<i class='fas fa-archive fa-fw'></i>
归档
</a>
</li>
<li>
<a class="flat-box" href=/categories/
id="categories"
>
<i class='fas fa-folder-open fa-fw'></i>
分类
</a>
</li>
<li>
<a class="flat-box" href=/friends/
id="friends"
>
<i class='fas fa-link fa-fw'></i>
友链
</a>
</li>
<li>
<a class="flat-box" href=/bbs/
id="bbs"
>
<i class='fas fa-comment-alt fa-fw'></i>
留言
</a>
</li>
<li>
<a class="flat-box" href=/about/
id="about"
>
<i class='fas fa-info-circle fa-fw'></i>
关于
</a>
</li>
</ul>
<script>setLoadingBarProgress(40);</script>
<div class="l_body nocover">
<div class='body-wrapper'>
<div class='l_main'>
<article id="post" class="post white-box shadow floatable article-type-post" itemscope itemprop="blogPost">
<section class='meta'>
<a title='Maven下的SSM整合' href='/SSM.html'><img class='thumbnail' src='https://cdn.jsdelivr.net/gh/crainyday/blog@master/imgs/more/more03.png'></a>
<div class="meta" id="header-meta">
<h1 class="title">
<a href="/SSM.html">
Maven下的SSM整合
</a>
</h1>
<div class='new-meta-box'>
<div class='new-meta-item author'>
<a href="https://crainyday.gitee.io" rel="nofollow">
<img src="https://cdn.jsdelivr.net/gh/crainyday/blog@master/lazyload.svg" data-original="https://cdn.jsdelivr.net/gh/crainyday/blog@master/avatar.png">
<p>crainyday</p>
</a>
</div>
<div class='new-meta-item category'>
<a href='/categories/Java/' rel="nofollow">
<i class="fas fa-folder-open" aria-hidden="true"></i>
<p>Java</p>
</a>
</div>
<div class="new-meta-item date">
<a class='notlink'>
<i class="fas fa-edit" aria-hidden="true"></i>
<p>发布于:2021年1月4日</p>
</a>
</div>
<div class="new-meta-item wordcount">
<a class='notlink'>
<i class="fas fa-keyboard" aria-hidden="true"></i>
<p>字数:4.1k字</p>
</a>
</div>
<div class="new-meta-item readtime">
<a class='notlink'>
<i class="fas fa-hourglass-half" aria-hidden="true"></i>
<p>时长:23分钟</p>
</a>
</div>
</div>
<hr>
</div>
</section>
<section class="article typo">
<div class="article-entry" itemprop="articleBody">
<p>在Eclipse下使用Maven创建和管理SSM项目.</p>
<a id="more"></a>
<h2 id="1-使用Maven搭建JavaWeb项目">1.使用Maven搭建JavaWeb项目</h2>
<blockquote>
<p> 具体搭建方法: <a href="maven_05.html#5-%E5%88%9B%E5%BB%BAMaven%E7%89%88%E7%9A%84Web%E5%B7%A5%E7%A8%8B">创建Maven版的Web工程</a></p>
</blockquote>
<h2 id="2-使用Maven导入SSM框架所需jar">2.使用Maven导入SSM框架所需jar</h2>
<blockquote>
<p> 项目的pom.xml如下:</p>
</blockquote>
<details>
<summary>
SSM整合的pom文件:One More Thing 👇
</summary>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag"><<span class="name">project</span> <span class="attr">xmlns</span>=<span class="string">"http://maven.apache.org/POM/4.0.0"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:xsi</span>=<span class="string">"http://www.w3.org/2001/XMLSchema-instance"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xsi:schemaLocation</span>=<span class="string">"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">modelVersion</span>></span>4.0.0<span class="tag"></<span class="name">modelVersion</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>com.crainyday.ssmr<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>ssmr<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>0.0.1-SNAPSHOT<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">packaging</span>></span>war<span class="tag"></<span class="name">packaging</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">properties</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">project.build.sourceEncoding</span>></span>UTF-8<span class="tag"></<span class="name">project.build.sourceEncoding</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">maven.compiler.source</span>></span>1.7<span class="tag"></<span class="name">maven.compiler.source</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">maven.compiler.target</span>></span>1.7<span class="tag"></<span class="name">maven.compiler.target</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">junit.version</span>></span>4.12<span class="tag"></<span class="name">junit.version</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">spring.version</span>></span>5.2.5.RELEASE<span class="tag"></<span class="name">spring.version</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">taglibs.version</span>></span>1.2.5<span class="tag"></<span class="name">taglibs.version</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">mysql.version</span>></span>5.1.48<span class="tag"></<span class="name">mysql.version</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">c3p0.version</span>></span>0.9.5.5<span class="tag"></<span class="name">c3p0.version</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">mybatis.version</span>></span>3.5.4<span class="tag"></<span class="name">mybatis.version</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">jackson.version</span>></span>2.10.3<span class="tag"></<span class="name">jackson.version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">properties</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependencies</span>></span></span><br><span class="line"> <span class="comment"><!-- junit 单元测试 --></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>junit<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>junit<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${junit.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">scope</span>></span>test<span class="tag"></<span class="name">scope</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="comment"><!-- log4j 日志 --></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>log4j<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>log4j<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>1.2.17<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.slf4j<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>slf4j-log4j12<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>2.0.0-alpha1<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">scope</span>></span>compile<span class="tag"></<span class="name">scope</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="comment"><!-- servlet --></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>javax.servlet<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>javax.servlet-api<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>4.0.1<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">scope</span>></span>provided<span class="tag"></<span class="name">scope</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="comment"><!-- Spring 及 SpringMVC 的 jar --></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.springframework<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>spring-core<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${spring.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.springframework<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>spring-test<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${spring.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.springframework<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>spring-context<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${spring.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.springframework<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>spring-aspects<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${spring.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.springframework<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>spring-jdbc<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${spring.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.springframework<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>spring-test<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${spring.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.springframework<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>spring-web<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${spring.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.springframework<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>spring-webmvc<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${spring.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="comment"><!-- SpringAOP 相关依赖 jar --></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>aopalliance<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>aopalliance<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>1.0<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>cglib<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>cglib<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>3.3.0<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.aspectj<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>aspectjweaver<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>1.9.5<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="comment"><!-- taglib 标签库jar --></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.apache.taglibs<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>taglibs-standard-impl<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${taglibs.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.apache.taglibs<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>taglibs-standard-spec<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${taglibs.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="comment"><!-- 数据库相关 jar --></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>mysql<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>mysql-connector-java<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${mysql.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>com.mchange<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>c3p0<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${c3p0.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="comment"><!-- mybatis 及 mybatis-spring --></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.mybatis<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>mybatis<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${mybatis.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.mybatis.generator<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>mybatis-generator-core<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>1.4.0<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>org.mybatis<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>mybatis-spring<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>2.0.4<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="comment"><!-- Json数据处理相关jackson包 --></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>com.fasterxml.jackson.core<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>jackson-databind<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${jackson.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>com.fasterxml.jackson.core<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>jackson-core<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${jackson.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">groupId</span>></span>com.fasterxml.jackson.core<span class="tag"></<span class="name">groupId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">artifactId</span>></span>jackson-annotations<span class="tag"></<span class="name">artifactId</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">version</span>></span>${jackson.version}<span class="tag"></<span class="name">version</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependency</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">dependencies</span>></span></span><br><span class="line"><span class="tag"></<span class="name">project</span>></span></span><br></pre></td></tr></table></figure>
</details>
<h2 id="3-配置项目的web-xml">3.配置项目的web.xml</h2>
<h3 id="①关于整合">①关于整合</h3>
<blockquote>
<p> 我们有两种整合方法:</p>
<ul>
<li>
<p>①同时配置Spring IOC和Spring MVC IOC</p>
<blockquote>
<p> 通常情况下, 我们都是配置两个IOC容器的.</p>
<ul>
<li>将类似于数据源、事务、 整合其他框架的配置都是放在 Spring 的配置文件中, 还有 Service 和 Dao 对象等.</li>
<li>而 Spring MVC 的 IOC 只负责HandlerMapping 映射策略、各种 Controller 控制器、各种视图解析、拦截器、LocalResolver 国际化处理等的配置.</li>
</ul>
</blockquote>
</li>
<li>
<p>②只配置Spring MVC IOC: 将所有配置都放在 SpringMVC 的配置文件中. 也可以分多个 Spring 的配置文件, 然后使用 import 节点导入其他的配置文件.</p>
</li>
<li>
<p><font style="color:red;">在这里, 我们用第①种方法.</font></p>
</li>
</ul>
</blockquote>
<h3 id="②在web-xml中配置字符过滤器和RESTFUL风格API过滤器">②在web.xml中配置字符过滤器和RESTFUL风格API过滤器</h3>
<blockquote>
<ul>
<li>
<p>为了解决在项目运行过程中出现的乱码问题, 需要配置字符过滤器, 将所有的编码格式统一为 UTF-8.</p>
</li>
<li>
<p>为了支持 RESTFUL API开发, 需要配置 RESTFUL 风格 API 过滤器.</p>
</li>
</ul>
<p>在 web.xml 中加入如下配置:</p>
</blockquote>
<details>
<summary>
One More Thing 👇
</summary>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta"><?xml version="1.0" encoding="UTF-8"?></span></span><br><span class="line"><span class="tag"><<span class="name">web-app</span> <span class="attr">id</span>=<span class="string">"WebApp_ID"</span> <span class="attr">version</span>=<span class="string">"4.0"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns</span>=<span class="string">"http://xmlns.jcp.org/xml/ns/javaee"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:xsi</span>=<span class="string">"http://www.w3.org/2001/XMLSchema-instance"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xsi:schemaLocation</span>=<span class="string">"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"</span>></span></span><br><span class="line"> <span class="comment"><!-- 字符过滤器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>CharacterEncodingFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-class</span>></span>org.springframework.web.filter.CharacterEncodingFilter<span class="tag"></<span class="name">filter-class</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">init-param</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-name</span>></span>Encoding<span class="tag"></<span class="name">param-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-value</span>></span>UTF-8<span class="tag"></<span class="name">param-value</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">init-param</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-mapping</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>CharacterEncodingFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">url-pattern</span>></span>/*<span class="tag"></<span class="name">url-pattern</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter-mapping</span>></span></span><br><span class="line"> <span class="comment"><!-- RESTFUL 风格 API 过滤器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>HiddenHttpMethodFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-class</span>></span>org.springframework.web.filter.HiddenHttpMethodFilter<span class="tag"></<span class="name">filter-class</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-mapping</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>HiddenHttpMethodFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">url-pattern</span>></span>/*<span class="tag"></<span class="name">url-pattern</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter-mapping</span>></span></span><br><span class="line"><span class="tag"></<span class="name">web-app</span>></span></span><br></pre></td></tr></table></figure>
</details>
<h3 id="③在web-xml中配置-Spring-IOC">③在web.xml中配置 Spring IOC</h3>
<blockquote>
<p> 我们希望在WEB 应用服务器启动时就创建Spring IOC, 因此需要监听器.</p>
<p>通过监听器来监听 ServletContext 对象的创建, 监听到ServletContext对象被创建, 就创建SpringIOC容器.</p>
<p><font style="color:red;">这里不需要自定义 Listener 来创建 Spring IOC, 直接使用 SpringMVC 提供的 ContextLoaderListener 即可.</font></p>
<p>在 web.xml 中加入如下配置:</p>
<p>(注意: 需要在项目的 resources 目录下创建 spring.xml 文件)</p>
</blockquote>
<details>
<summary>
One More Thing 👇
</summary>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta"><?xml version="1.0" encoding="UTF-8"?></span></span><br><span class="line"><span class="tag"><<span class="name">web-app</span> <span class="attr">id</span>=<span class="string">"WebApp_ID"</span> <span class="attr">version</span>=<span class="string">"4.0"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns</span>=<span class="string">"http://xmlns.jcp.org/xml/ns/javaee"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:xsi</span>=<span class="string">"http://www.w3.org/2001/XMLSchema-instance"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xsi:schemaLocation</span>=<span class="string">"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"</span>></span></span><br><span class="line"> <span class="comment"><!-- 字符过滤器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>CharacterEncodingFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-class</span>></span>org.springframework.web.filter.CharacterEncodingFilter<span class="tag"></<span class="name">filter-class</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">init-param</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-name</span>></span>Encoding<span class="tag"></<span class="name">param-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-value</span>></span>UTF-8<span class="tag"></<span class="name">param-value</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">init-param</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-mapping</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>CharacterEncodingFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">url-pattern</span>></span>/*<span class="tag"></<span class="name">url-pattern</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter-mapping</span>></span></span><br><span class="line"> <span class="comment"><!-- RESTFUL 风格 API 过滤器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>HiddenHttpMethodFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-class</span>></span>org.springframework.web.filter.HiddenHttpMethodFilter<span class="tag"></<span class="name">filter-class</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-mapping</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>HiddenHttpMethodFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">url-pattern</span>></span>/*<span class="tag"></<span class="name">url-pattern</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter-mapping</span>></span></span><br><span class="line"> <span class="comment"><!-- 加载 Spring 容器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">context-param</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-name</span>></span>contextConfigLocation<span class="tag"></<span class="name">param-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-value</span>></span>classpath:spring.xml<span class="tag"></<span class="name">param-value</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">context-param</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">listener</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">listener-class</span>></span>org.springframework.web.context.ContextLoaderListener<span class="tag"></<span class="name">listener-class</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">listener</span>></span></span><br><span class="line"><span class="tag"></<span class="name">web-app</span>></span></span><br></pre></td></tr></table></figure>
</details>
<h3 id="④在web-xml中配置-SpringMVC-IOC">④在web.xml中配置 SpringMVC IOC</h3>
<blockquote>
<p> 在完成对 ContextLoaderListener 的初始化后, Web 容器开始初始化 DispatcherServlet(前端控制器). 其作为一个Servlet, 所有的 Web 请求都需要通过它来处理, 然后进行转发、匹配、数据处理后, 并转由页面进行展现, 它可以说是 SpringMVC 最核心的部分.</p>
<p>在 web.xml 中加入如下配置:</p>
<p><font style="color:red;">(注意: 这里的 web.xml 是项目的 web.xml 的基础最终配置)</font></p>
</blockquote>
<details>
<summary>
web.xml文件:One More Thing 👇
</summary>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta"><?xml version="1.0" encoding="UTF-8"?></span></span><br><span class="line"><span class="tag"><<span class="name">web-app</span> <span class="attr">id</span>=<span class="string">"WebApp_ID"</span> <span class="attr">version</span>=<span class="string">"4.0"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns</span>=<span class="string">"http://xmlns.jcp.org/xml/ns/javaee"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:xsi</span>=<span class="string">"http://www.w3.org/2001/XMLSchema-instance"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xsi:schemaLocation</span>=<span class="string">"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"</span>></span></span><br><span class="line"> <span class="comment"><!-- 字符过滤器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>CharacterEncodingFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-class</span>></span>org.springframework.web.filter.CharacterEncodingFilter<span class="tag"></<span class="name">filter-class</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">init-param</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-name</span>></span>Encoding<span class="tag"></<span class="name">param-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-value</span>></span>UTF-8<span class="tag"></<span class="name">param-value</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">init-param</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-mapping</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>CharacterEncodingFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">url-pattern</span>></span>/*<span class="tag"></<span class="name">url-pattern</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter-mapping</span>></span></span><br><span class="line"> <span class="comment"><!-- RESTFUL 风格 API 过滤器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>HiddenHttpMethodFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-class</span>></span>org.springframework.web.filter.HiddenHttpMethodFilter<span class="tag"></<span class="name">filter-class</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-mapping</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">filter-name</span>></span>HiddenHttpMethodFilter<span class="tag"></<span class="name">filter-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">url-pattern</span>></span>/*<span class="tag"></<span class="name">url-pattern</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">filter-mapping</span>></span></span><br><span class="line"> <span class="comment"><!-- 加载 Spring 容器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">context-param</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-name</span>></span>contextConfigLocation<span class="tag"></<span class="name">param-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-value</span>></span>classpath:spring.xml<span class="tag"></<span class="name">param-value</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">context-param</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">listener</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">listener-class</span>></span>org.springframework.web.context.ContextLoaderListener<span class="tag"></<span class="name">listener-class</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">listener</span>></span></span><br><span class="line"> <span class="comment"><!-- 加载 SpringMVC 容器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">servlet</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">servlet-name</span>></span>springDispatcherServlet<span class="tag"></<span class="name">servlet-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">servlet-class</span>></span>org.springframework.web.servlet.DispatcherServlet<span class="tag"></<span class="name">servlet-class</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">init-param</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-name</span>></span>contextConfigLocation<span class="tag"></<span class="name">param-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">param-value</span>></span>classpath:spring-mvc.xml<span class="tag"></<span class="name">param-value</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">init-param</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">load-on-startup</span>></span>1<span class="tag"></<span class="name">load-on-startup</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">servlet</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">servlet-mapping</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">servlet-name</span>></span>springDispatcherServlet<span class="tag"></<span class="name">servlet-name</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">url-pattern</span>></span>/<span class="tag"></<span class="name">url-pattern</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">servlet-mapping</span>></span></span><br><span class="line"><span class="tag"></<span class="name">web-app</span>></span></span><br></pre></td></tr></table></figure>
</details>
<h2 id="4-配置各自IOC的xml">4.配置各自IOC的xml</h2>
<p><font style="color:red;font-weight:bolder;">注意: 以下所有的配置文件, 均在项目的 classpath 下.</font></p>
<blockquote>
<p> 这里我们是创建了两个 IOC, 需要配置两个 xml 文件: spring.xml 和 spring-mvc.xml.</p>
<p>首先, 他们两个所做的功能不同, 故需要扫描加载不同的 Class.</p>
<p>一个指定扫描包, 一个排除扫描包.</p>
<p>注意: 指定扫描时, 需要设置属性<code>use-default-filters="false"</code>.</p>
<p>MyBatis相关配置见: <a href="#5.MyBatis%E7%9B%B8%E5%85%B3%E9%85%8D%E7%BD%AE">MyBatis相关配置</a>.</p>
</blockquote>
<h3 id="①配置spring-xml">①配置spring.xml</h3>
<details>
<summary>
Spring容器的配置文件:One More Thing 👇
</summary>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta"><?xml version="1.0" encoding="UTF-8"?></span></span><br><span class="line"><span class="tag"><<span class="name">beans</span> <span class="attr">xmlns</span>=<span class="string">"http://www.springframework.org/schema/beans"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:xsi</span>=<span class="string">"http://www.w3.org/2001/XMLSchema-instance"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:context</span>=<span class="string">"http://www.springframework.org/schema/context"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:mybatis-spring</span>=<span class="string">"http://mybatis.org/schema/mybatis-spring"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:tx</span>=<span class="string">"http://www.springframework.org/schema/tx"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:aop</span>=<span class="string">"http://www.springframework.org/schema/aop"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:task</span>=<span class="string">"http://www.springframework.org/schema/task"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xsi:schemaLocation</span>=<span class="string">"http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd</span></span></span><br><span class="line"><span class="tag"><span class="string"> http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.3.xsd</span></span></span><br><span class="line"><span class="tag"><span class="string"> http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</span></span></span><br><span class="line"><span class="tag"><span class="string"> http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd</span></span></span><br><span class="line"><span class="tag"><span class="string"> http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd</span></span></span><br><span class="line"><span class="tag"><span class="string"> http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd"</span>></span></span><br><span class="line"> <span class="comment"><!-- 排除扫描 --></span></span><br><span class="line"> <span class="tag"><<span class="name">context:component-scan</span></span></span><br><span class="line"><span class="tag"> <span class="attr">base-package</span>=<span class="string">"ssm"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">context:exclude-filter</span> <span class="attr">type</span>=<span class="string">"annotation"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">expression</span>=<span class="string">"org.springframework.stereotype.Controller"</span> /></span></span><br><span class="line"> <span class="tag"><<span class="name">context:exclude-filter</span> <span class="attr">type</span>=<span class="string">"annotation"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">expression</span>=<span class="string">"org.springframework.web.bind.annotation.RestControllerAdvice"</span> /></span></span><br><span class="line"> <span class="tag"></<span class="name">context:component-scan</span>></span></span><br><span class="line"> <span class="comment"><!-- 载入 properties 配置文件 --></span></span><br><span class="line"> <span class="tag"><<span class="name">context:property-placeholder</span></span></span><br><span class="line"><span class="tag"> <span class="attr">location</span>=<span class="string">"classpath:db.properties"</span> /></span></span><br><span class="line"> <span class="comment"><!-- 配置数据源 --></span></span><br><span class="line"> <span class="tag"><<span class="name">bean</span> <span class="attr">id</span>=<span class="string">"dataSource"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">class</span>=<span class="string">"com.mchange.v2.c3p0.ComboPooledDataSource"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"driverClass"</span> <span class="attr">value</span>=<span class="string">"${jdbc.driver}"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"jdbcUrl"</span> <span class="attr">value</span>=<span class="string">"${jdbc.url}"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"user"</span> <span class="attr">value</span>=<span class="string">"${jdbc.username}"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"password"</span> <span class="attr">value</span>=<span class="string">"${jdbc.password}"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"acquireRetryAttempts"</span> <span class="attr">value</span>=<span class="string">"0"</span> /></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"maxIdleTime"</span> <span class="attr">value</span>=<span class="string">"3600"</span> /></span></span><br><span class="line"> <span class="comment"><!-- 每隔固定时间, 需要用 select 1 语句检测数据库连接, 避免数据库连接超时 --></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"preferredTestQuery"</span> <span class="attr">value</span>=<span class="string">"select 1"</span> /></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"idleConnectionTestPeriod"</span> <span class="attr">value</span>=<span class="string">"18000"</span> /></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"testConnectionOnCheckout"</span> <span class="attr">value</span>=<span class="string">"false"</span> /></span></span><br><span class="line"> <span class="tag"></<span class="name">bean</span>></span></span><br><span class="line"> <span class="comment"><!-- 配置事务 --></span></span><br><span class="line"> <span class="tag"><<span class="name">bean</span> <span class="attr">id</span>=<span class="string">"transactionManager"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">class</span>=<span class="string">"org.springframework.jdbc.datasource.DataSourceTransactionManager"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"dataSource"</span> <span class="attr">ref</span>=<span class="string">"dataSource"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">bean</span>></span></span><br><span class="line"> <span class="comment"><!-- 基于注解使用事务 --></span></span><br><span class="line"> <span class="tag"><<span class="name">tx:annotation-driven</span></span></span><br><span class="line"><span class="tag"> <span class="attr">transaction-manager</span>=<span class="string">"transactionManager"</span> /></span></span><br><span class="line"> <span class="comment"><!-- 配置 MyBatis --></span></span><br><span class="line"> <span class="tag"><<span class="name">bean</span> <span class="attr">class</span>=<span class="string">"org.mybatis.spring.SqlSessionFactoryBean"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"configLocation"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">value</span>=<span class="string">"classpath:mybatis-config.xml"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"mapperLocations"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">value</span>=<span class="string">"classpath:mapping/*.xml"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"dataSource"</span> <span class="attr">ref</span>=<span class="string">"dataSource"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"typeAliasesPackage"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">value</span>=<span class="string">"ssm.model"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">bean</span>></span></span><br><span class="line"> <span class="comment"><!-- MyBatis的扫描包 --></span></span><br><span class="line"> <span class="tag"><<span class="name">mybatis-spring:scan</span> <span class="attr">base-package</span>=<span class="string">"ssm.mapper"</span> /></span></span><br><span class="line"><span class="tag"></<span class="name">beans</span>></span></span><br></pre></td></tr></table></figure>
</details>
<p>②配置spring-mvc.xml</p>
<details>
<summary>
spring-mvc容器的配置文件:One More Thing 👇
</summary>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta"><?xml version="1.0" encoding="UTF-8"?></span></span><br><span class="line"><span class="tag"><<span class="name">beans</span> <span class="attr">xmlns</span>=<span class="string">"http://www.springframework.org/schema/beans"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:xsi</span>=<span class="string">"http://www.w3.org/2001/XMLSchema-instance"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:context</span>=<span class="string">"http://www.springframework.org/schema/context"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xmlns:mvc</span>=<span class="string">"http://www.springframework.org/schema/mvc"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">xsi:schemaLocation</span>=<span class="string">"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd</span></span></span><br><span class="line"><span class="tag"><span class="string"> http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd</span></span></span><br><span class="line"><span class="tag"><span class="string"> http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd"</span>></span></span><br><span class="line"> <span class="comment"><!-- 指定扫描 --></span></span><br><span class="line"> <span class="tag"><<span class="name">context:component-scan</span></span></span><br><span class="line"><span class="tag"> <span class="attr">base-package</span>=<span class="string">"ssm"</span> <span class="attr">use-default-filters</span>=<span class="string">"false"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">context:include-filter</span> <span class="attr">type</span>=<span class="string">"annotation"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">expression</span>=<span class="string">"org.springframework.stereotype.Controller"</span> /></span></span><br><span class="line"> <span class="tag"><<span class="name">context:include-filter</span> <span class="attr">type</span>=<span class="string">"annotation"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">expression</span>=<span class="string">"org.springframework.web.bind.annotation.RestControllerAdvice"</span>/></span></span><br><span class="line"> <span class="tag"></<span class="name">context:component-scan</span>></span></span><br><span class="line"> <span class="comment"><!-- 视图解析器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">bean</span></span></span><br><span class="line"><span class="tag"> <span class="attr">class</span>=<span class="string">"org.springframework.web.servlet.view.InternalResourceViewResolver"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"prefix"</span> <span class="attr">value</span>=<span class="string">"/WEB-INF/views/"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"suffix"</span> <span class="attr">value</span>=<span class="string">".jsp"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">bean</span>></span></span><br><span class="line"> <span class="comment"><!-- 关于文件上传的配置操作 --></span></span><br><span class="line"> <span class="tag"><<span class="name">bean</span> <span class="attr">id</span>=<span class="string">"multipartResolver"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">class</span>=<span class="string">"org.springframework.web.multipart.commons.CommonsMultipartResolver"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"defaultEncoding"</span> <span class="attr">value</span>=<span class="string">"utf-8"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="comment"><!-- 最大上传文件大小: 10MB --></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"maxUploadSize"</span> <span class="attr">value</span>=<span class="string">"10485760"</span>></span><span class="tag"></<span class="name">property</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">bean</span>></span></span><br><span class="line"> <span class="comment"><!-- 拦截器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">mvc:interceptors</span>></span></span><br><span class="line"> <span class="comment"><!-- 令牌拦截器 --></span></span><br><span class="line"> <span class="tag"><<span class="name">mvc:interceptor</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">mvc:mapping</span> <span class="attr">path</span>=<span class="string">"/**"</span> /></span></span><br><span class="line"> <span class="comment"><!-- 不需要拦截的路径 --></span></span><br><span class="line"> <span class="tag"><<span class="name">mvc:exclude-mapping</span> <span class="attr">path</span>=<span class="string">"/wxLogin"</span> /></span></span><br><span class="line"> <span class="tag"><<span class="name">mvc:exclude-mapping</span> <span class="attr">path</span>=<span class="string">"/testLogin"</span>/></span></span><br><span class="line"> <span class="tag"><<span class="name">mvc:exclude-mapping</span> <span class="attr">path</span>=<span class="string">"/qrcode/**"</span>/></span></span><br><span class="line"> <span class="tag"><<span class="name">bean</span> <span class="attr">class</span>=<span class="string">"com.crainyday.sport.utils.TokenInterceptor"</span>></span><span class="tag"></<span class="name">bean</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">mvc:interceptor</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">mvc:interceptors</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">mvc:default-servlet-handler</span> /></span></span><br><span class="line"> <span class="tag"><<span class="name">mvc:annotation-driven</span> /></span></span><br><span class="line"><span class="tag"></<span class="name">beans</span>></span></span><br></pre></td></tr></table></figure>
</details>
<h3 id="5-MyBatis以及其他配置">5.MyBatis以及其他配置</h3>
<h3 id="①数据源配置">①数据源配置</h3>
<blockquote>
<p> 这里用的是MySQL数据库, db.properties:</p>
</blockquote>
<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">jdbc.driver</span>=<span class="string">com.mysql.jdbc.Driver</span></span><br><span class="line"><span class="meta">jdbc.url</span>=<span class="string">jdbc:mysql://localhost:3306/javaee?useSSL=false</span></span><br><span class="line"><span class="meta">jdbc.username</span>=<span class="string">root</span></span><br><span class="line"><span class="meta">jdbc.password</span>=<span class="string">root</span></span><br></pre></td></tr></table></figure>
<h3 id="②log4j配置">②log4j配置</h3>
<blockquote>
<p> 这里用的 slf4j+log4j 的方式做的日志处理, log4j.properties:</p>
<p>(可以参看这里的, <a href="https://my.oschina.net/u/3387320/blog/2875661" target="_blank" rel="noopener">SSM框架下log4j的配置和使用</a> .)</p>
</blockquote>
<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">log4j.rootLogger</span>=<span class="string">ERROR, stdout</span></span><br><span class="line"><span class="meta">log4j.appender.stdout</span>=<span class="string">org.apache.log4j.ConsoleAppender</span></span><br><span class="line"><span class="meta">log4j.appender.stdout.layout</span>=<span class="string">org.apache.log4j.PatternLayout</span></span><br><span class="line"><span class="meta">log4j.appender.stdout.layout.ConversionPattern</span>=<span class="string">%-5p %d{MM-dd HH:mm:ss,SSS} %m (%F:%L) \n</span></span><br></pre></td></tr></table></figure>
<h3 id="③MyBatis配置">③MyBatis配置</h3>
<blockquote>
<p> 可以使用 MyBatisGenerator 来自动生成某些相关代码.</p>
</blockquote>
<details>
<summary>
MyBatisGenerator 的配置文件 generatorConfig.xml: One More Thing 👇
</summary>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta"><?xml version="1.0" encoding="UTF-8"?></span></span><br><span class="line"><span class="meta"><!DOCTYPE generatorConfiguration</span></span><br><span class="line"><span class="meta"> PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"</span></span><br><span class="line"><span class="meta"> "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"></span></span><br><span class="line"><span class="tag"><<span class="name">generatorConfiguration</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">properties</span> <span class="attr">resource</span>=<span class="string">"db.properties"</span>/></span></span><br><span class="line"> <span class="comment"><!--数据库驱动--></span></span><br><span class="line"> <span class="tag"><<span class="name">context</span> <span class="attr">id</span>=<span class="string">"DB2Tables"</span> <span class="attr">targetRuntime</span>=<span class="string">"MyBatis3"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">commentGenerator</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"suppressDate"</span> <span class="attr">value</span>=<span class="string">"true"</span>/></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"suppressAllComments"</span> <span class="attr">value</span>=<span class="string">"true"</span>/></span></span><br><span class="line"> <span class="tag"></<span class="name">commentGenerator</span>></span></span><br><span class="line"> <span class="comment"><!--数据库链接地址账号密码--></span></span><br><span class="line"> <span class="tag"><<span class="name">jdbcConnection</span> <span class="attr">driverClass</span>=<span class="string">"com.mysql.jdbc.Driver"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">connectionURL</span>=<span class="string">"${jdbc.url}"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">userId</span>=<span class="string">"${jdbc.username}"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">password</span>=<span class="string">"${jdbc.password}"</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">jdbcConnection</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">javaTypeResolver</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"forceBigDecimals"</span> <span class="attr">value</span>=<span class="string">"false"</span>/></span></span><br><span class="line"> <span class="tag"></<span class="name">javaTypeResolver</span>></span></span><br><span class="line"> <span class="comment"><!--生成 Model 类存放位置--></span></span><br><span class="line"> <span class="tag"><<span class="name">javaModelGenerator</span> <span class="attr">targetPackage</span>=<span class="string">"ssm.model"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">targetProject</span>=<span class="string">"src/main/java"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"enableSubPackages"</span> <span class="attr">value</span>=<span class="string">"true"</span>/></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"trimStrings"</span> <span class="attr">value</span>=<span class="string">"true"</span>/></span></span><br><span class="line"> <span class="tag"></<span class="name">javaModelGenerator</span>></span></span><br><span class="line"> <span class="comment"><!--生成映射文件存放位置--></span></span><br><span class="line"> <span class="tag"><<span class="name">sqlMapGenerator</span> <span class="attr">targetPackage</span>=<span class="string">"mapping"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">targetProject</span>=<span class="string">"src/main/resources"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"enableSubPackages"</span> <span class="attr">value</span>=<span class="string">"true"</span>/></span></span><br><span class="line"> <span class="tag"></<span class="name">sqlMapGenerator</span>></span></span><br><span class="line"> <span class="comment"><!--生成Dao类存放位置--></span></span><br><span class="line"> <span class="tag"><<span class="name">javaClientGenerator</span> <span class="attr">type</span>=<span class="string">"XMLMAPPER"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">targetPackage</span>=<span class="string">"ssm.mapper"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">targetProject</span>=<span class="string">"src/main/java"</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">property</span> <span class="attr">name</span>=<span class="string">"enableSubPackages"</span> <span class="attr">value</span>=<span class="string">"true"</span>/></span></span><br><span class="line"> <span class="tag"></<span class="name">javaClientGenerator</span>></span></span><br><span class="line"> <span class="comment"><!--生成对应表及类名--></span></span><br><span class="line"> <span class="comment"><!-- </span></span><br><span class="line"><span class="comment"> enableInsert="true": 生成 insert 和 insertSelective 语句</span></span><br><span class="line"><span class="comment"> enableDeleteByPrimaryKey="true": 生成 deleteByPrimaryKey 语句</span></span><br><span class="line"><span class="comment"> enableUpdateByPrimaryKey="true": 生成 updateByPrimaryKey 和 updateByPrimaryKeySelective 语句</span></span><br><span class="line"><span class="comment"> enableSelectByPrimaryKey="true": 生成 selectByPrimaryKey 语句</span></span><br><span class="line"><span class="comment"> --></span></span><br><span class="line"> <span class="tag"><<span class="name">table</span> <span class="attr">tableName</span>=<span class="string">"customer"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">domainObjectName</span>=<span class="string">"Customer"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">enableDeleteByExample</span>=<span class="string">"false"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">enableUpdateByExample</span>=<span class="string">"false"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">enableCountByExample</span>=<span class="string">"false"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">enableSelectByExample</span>=<span class="string">"false"</span> </span></span><br><span class="line"><span class="tag"> <span class="attr">selectByExampleQueryId</span>=<span class="string">"false"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">selectByPrimaryKeyQueryId</span>=<span class="string">"false"</span></span></span><br><span class="line"><span class="tag"> </span></span><br><span class="line"><span class="tag"> <span class="attr">enableInsert</span>=<span class="string">"true"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">enableDeleteByPrimaryKey</span>=<span class="string">"true"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">enableUpdateByPrimaryKey</span>=<span class="string">"true"</span></span></span><br><span class="line"><span class="tag"> <span class="attr">enableSelectByPrimaryKey</span>=<span class="string">"true"</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">table</span>></span></span><br><span class="line"> <span class="tag"></<span class="name">context</span>></span></span><br><span class="line"><span class="tag"></<span class="name">generatorConfiguration</span>></span></span><br></pre></td></tr></table></figure>
</details>
<details>
<summary>
MyBatisGenerator 的使用: One More Thing 👇
</summary>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> ssm;</span><br><span class="line"><span class="keyword">import</span> java.io.File;</span><br><span class="line"><span class="keyword">import</span> java.util.ArrayList;</span><br><span class="line"><span class="keyword">import</span> java.util.List;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> org.mybatis.generator.api.MyBatisGenerator;</span><br><span class="line"><span class="keyword">import</span> org.mybatis.generator.config.Configuration;</span><br><span class="line"><span class="keyword">import</span> org.mybatis.generator.config.xml.ConfigurationParser;</span><br><span class="line"><span class="keyword">import</span> org.mybatis.generator.internal.DefaultShellCallback;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MBGTest</span> </span>{</span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>{</span><br><span class="line"> <span class="keyword">try</span> {</span><br><span class="line"> List<String> warnings = <span class="keyword">new</span> ArrayList<String>();</span><br><span class="line"> <span class="keyword">boolean</span> overwrite = <span class="keyword">true</span>;</span><br><span class="line"> String cfile = <span class="string">"/generatorConfig.xml"</span>;</span><br><span class="line"> File configFile = <span class="keyword">new</span> File(MBGTest.class.getResource(cfile).getFile());</span><br><span class="line"> ConfigurationParser cp = <span class="keyword">new</span> ConfigurationParser(warnings);</span><br><span class="line"> Configuration config = cp.parseConfiguration(configFile);</span><br><span class="line"> DefaultShellCallback callback = <span class="keyword">new</span> DefaultShellCallback(overwrite);</span><br><span class="line"> MyBatisGenerator myBatisGenerator = <span class="keyword">new</span> MyBatisGenerator(config, callback, warnings);</span><br><span class="line"> myBatisGenerator.generate(<span class="keyword">null</span>);</span><br><span class="line"> <span class="keyword">for</span> (String warning : warnings) {</span><br><span class="line"> System.err.println(warning);</span><br><span class="line"> }</span><br><span class="line"> System.out.println(<span class="string">"生成结束......"</span>);</span><br><span class="line"> } <span class="keyword">catch</span> (Exception e) {</span><br><span class="line"> e.printStackTrace();</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
</details>
<p>mybatis-config.xml:</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta"><?xml version="1.0" encoding="UTF-8" ?></span></span><br><span class="line"><span class="meta"><!DOCTYPE configuration</span></span><br><span class="line"><span class="meta"> PUBLIC "-//mybatis.org//DTD Config 3.0//EN"</span></span><br><span class="line"><span class="meta"> "http://mybatis.org/dtd/mybatis-3-config.dtd"></span></span><br><span class="line"><span class="tag"><<span class="name">configuration</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">settings</span>></span></span><br><span class="line"> <span class="tag"><<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"mapUnderscoreToCamelCase"</span> <span class="attr">value</span>=<span class="string">"true"</span> /></span></span><br><span class="line"> <span class="tag"><<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"jdbcTypeForNull"</span> <span class="attr">value</span>=<span class="string">"NULL"</span> /></span></span><br><span class="line"> <span class="tag"><<span class="name">setting</span> <span class="attr">name</span>=<span class="string">"lazyLoadingEnabled"</span> <span class="attr">value</span>=<span class="string">"true"</span> /></span></span><br><span class="line"> <span class="tag"></<span class="name">settings</span>></span></span><br><span class="line"><span class="tag"></<span class="name">configuration</span>></span></span><br></pre></td></tr></table></figure>
<br>
<section class="widget copyright desktop mobile">
<div class='content'>
<blockquote>
<p>博客内容遵循 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议</p>
<p>本文永久链接是:<a href=https://crainyday.gitee.io/SSM.html>https://crainyday.gitee.io/SSM.html</a></p>
</blockquote>
</div>
</section>
<section class="widget qrcode desktop mobile">
<div class='content article-entry'>
<fancybox><img src='https://cdn.jsdelivr.net/gh/crainyday/blog@master/alipay.png'
height='64px'
></fancybox>
<fancybox><img src='https://cdn.jsdelivr.net/gh/crainyday/blog@master/wechat.png'
height='64px'
></fancybox>
</div>
</section>
</div>
<section class='meta' id="footer-meta">
<div class='new-meta-box'>
<div class="new-meta-item date" itemprop="dateUpdated" datetime="2021-02-24T13:32:07+08:00">
<a class='notlink'>
<i class="fas fa-save" aria-hidden="true"></i>
<p>更新于:2021年2月24日</p>
</a>
</div>
<div class="new-meta-item meta-tags"><a class="tag" href="/tags/Spring/" rel="nofollow"><i class="fas fa-hashtag" aria-hidden="true"></i><p>Spring</p></a></div> <div class="new-meta-item meta-tags"><a class="tag" href="/tags/SpringMVC/" rel="nofollow"><i class="fas fa-hashtag" aria-hidden="true"></i><p>SpringMVC</p></a></div> <div class="new-meta-item meta-tags"><a class="tag" href="/tags/MyBatis/" rel="nofollow"><i class="fas fa-hashtag" aria-hidden="true"></i><p>MyBatis</p></a></div> <div class="new-meta-item meta-tags"><a class="tag" href="/tags/Maven/" rel="nofollow"><i class="fas fa-hashtag" aria-hidden="true"></i><p>Maven</p></a></div>
<div class="new-meta-item wordcount">
<a class='notlink'>
<i class="fas fa-keyboard" aria-hidden="true"></i>
<p>字数:4.1k字</p>
</a>
</div>
<div class="new-meta-item readtime">
<a class='notlink'>
<i class="fas fa-hourglass-half" aria-hidden="true"></i>
<p>时长:23分钟</p>
</a>
</div>
<div class="new-meta-item share -mob-share-list">
<div class="-mob-share-list share-body">
<a class="-mob-share-qq" title="" rel="external nofollow noopener noreferrer"
href="http://connect.qq.com/widget/shareqq/index.html?url=https://crainyday.gitee.io/SSM.html&title=Maven下的SSM整合 - CRainyDay&pics=https://cdn.jsdelivr.net/gh/crainyday/blog@master/imgs/more/more03.png&summary=在Eclipse下使用Maven创建和管理SSM项目."
>
<img src="https://cdn.jsdelivr.net/gh/crainyday/blog@master/lazyload.svg" data-original="https://cdn.jsdelivr.net/gh/xaoxuu/cdn-assets/logo/128/qq.png">
</a>
<a class="-mob-share-qzone" title="" rel="external nofollow noopener noreferrer"
href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=https://crainyday.gitee.io/SSM.html&title=Maven下的SSM整合 - CRainyDay&pics=https://cdn.jsdelivr.net/gh/crainyday/blog@master/imgs/more/more03.png&summary=在Eclipse下使用Maven创建和管理SSM项目."
>
<img src="https://cdn.jsdelivr.net/gh/crainyday/blog@master/lazyload.svg" data-original="https://cdn.jsdelivr.net/gh/xaoxuu/cdn-assets/logo/128/qzone.png">
</a>
<a class="-mob-share-weibo" title="" rel="external nofollow noopener noreferrer"
href="http://service.weibo.com/share/share.php?url=https://crainyday.gitee.io/SSM.html&title=Maven下的SSM整合 - CRainyDay&pics=https://cdn.jsdelivr.net/gh/crainyday/blog@master/imgs/more/more03.png&summary=在Eclipse下使用Maven创建和管理SSM项目."
>
<img src="https://cdn.jsdelivr.net/gh/crainyday/blog@master/lazyload.svg" data-original="https://cdn.jsdelivr.net/gh/xaoxuu/cdn-assets/logo/128/weibo.png">
</a>
<div class='hoverbox'>
<a><img src="https://cdn.jsdelivr.net/gh/crainyday/blog@master/lazyload.svg" data-original="https://cdn.jsdelivr.net/gh/xaoxuu/cdn-assets/logo/128/wechat.png"></a>
<div class='target'>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPgAAAD4CAAAAADkunTXAAACSklEQVR42u3cQXLCQAwEQP//0+QFlFcjmQqi9+Zg8PZymUgqrtePrgscHBwcHHwR/ArX7QNu7nv3eXfP6+4XHBwcHBx8I/w4ALy5/26DceB487nx+8HBwcHBwRfDTwPEU9dVeHm/4ODg4ODg4OXCwGnQSA8CHBwcHBwc/Dl4t1EADg4ODg4OPt9QuAseKSgdOPhYJwUcHBwcHPwfwbvB49PX8X7BwcHBwcEXwbvrtAFwGnzSYHO8X3BwcHBw8EXwqUZ/t5Bw+vfuIAI4ODg4OPhmeLVR0A0e19Aa66SAg4ODg4N/EbwaJNLXqwWKaoBpV2DAwcHBwcEXwLsNg3TgLz2oaoACBwcHBwffCD9t4FcDRnrA6fuPGwrg4ODg4OAL4NONgbTwcBqEHuukgIODg4ODL4BPBZMUlH7O+IAfODg4ODj4F8CngkE3uMSFhcMvDhwcHBwcfDN8KoB076s2EtqdFHBwcHBw8C+GVxv+1QdWGw3dwsPtNTg4ODg4+EJ4NSh0BwvSAYT2gAI4ODg4OPhieFoYqAaKNNiMNRTAwcHBwcEXwqsNgm6gmCpQnB4YODg4ODj4JvhT//ifBpd0gC8dNAAHBwcHB98E7zbiuxusBqZu4QQcHBwcHHwj/OnBgO6BTb0ODg4ODg6+GZ4GiClou9Bw93xwcHBwcHDw8R+sbQeTtKEADg4ODg4OXv5hvO7AXtz4AAcHBwcHXwyfChYpdLogAg4ODg4O/gvwNBhU75s64LQwAg4ODg4Ovgn+awscHBwcHHzB+gPvAwFbJvO60QAAAABJRU5ErkJggg==">
</div>
</div>
</div>
</div>
</div>
</section>
<div class="prev-next">
<a class='prev' href='/eclipse_01.html'>
<p class='title'><i class="fas fa-chevron-left" aria-hidden="true"></i>Eclipse常用配置</p>
<p class='content'>Eclipse 的常用插件.
Eclipse 的常用配置.
以免重装Eclipse后忘记配置.
一.Eclipse常用插件
注意: 点击 Help 中的 Eclipse Marketplac...</p>
</a>
<a class='next' href='/Git_GitHub_04.html'>
<p class='title'>安装Gitlab<i class="fas fa-chevron-right" aria-hidden="true"></i></p>
<p class='content'>在局域网环境下, 搭建局域网的代码托管中心------Gitlab.
这里我用Virtual Box虚拟机搭建的Gitlab.
系统是CentOS6.
注意, 一定要在安装前做一个系统的快照, ...</p>
</a>
</div>
</section>
</article>
<section class="widget related_posts shadow floatable desktop mobile">
<header>
<i class="fas fa-bookmark fa-fw" aria-hidden="true"></i><span class='name'>相关文章</span>
</header>
<div class="content">
</div>
</section>
<!-- 显示推荐文章和评论 -->
<article class="post white-box comments shadow floatable">
<section class="article typo">
<p ct><i class='fas fa-comments'></i> 评论</p>
<section id="comments">
<div id="valine_container" class="valine_thread">
<i class="fas fa-spinner fa-spin fa-fw"></i>
</div>
</section>
</section>
</article>
<!-- 根据页面mathjax变量决定是否加载MathJax数学公式js -->
<script>
window.subData = {
title: 'Maven下的SSM整合',
tools: true
}
</script>
</div>
<aside class='l_side'>
<section class="widget related_posts shadow floatable desktop mobile">
<header>
<i class="fas fa-bookmark fa-fw" aria-hidden="true"></i><span class='name'>相关文章</span>
</header>
<div class="content">
</div>
</section>
<section class="widget grid shadow floatable desktop mobile">
<header>
<i class="fas fa-map-signs fa-fw" aria-hidden="true"></i><span class='name'>实用文档</span>
</header>
<div class='content'>
<div class="grid navigation fixed">
<a class="flat-box" title="/maven_05.html" href="/maven_05.html"
id="maven_05.html">
<i class="fas fa-file fa-fw" aria-hidden="true"></i>
Maven工程
</a>
<a class="flat-box" title="/Flask.html" href="/Flask.html"
id="Flask.html">
<i class="fas fa-file fa-fw" aria-hidden="true"></i>
Flask应用
</a>
<a class="flat-box" title="/Hexo.html" href="/Hexo.html"
id="Hexo.html">
<i class="fas fa-file fa-fw" aria-hidden="true"></i>
Gitee搭站
</a>
<a class="flat-box" title="/Ubuntu_006.html" href="/Ubuntu_006.html"