登录

立即登录

去注册

忘记密码?

验证码登录

点击获取验证码

立即登录

去注册

注册

点击获取验证码

立即注册

找回密码

点击获取验证码

确定

全部资讯

全部资讯   / 百度-Java中级面试考点(2020年)

百度-Java中级面试考点(2020年)

2021-12-24 13:53:33

<div class="WordSection1"> <p class="MsoNormal" style="margin-top:9.5pt;text-indent:2.35pt;line-height:88%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.45pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">B</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.4pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">ea</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.45pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">n</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.4pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">Fa</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.35pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">c</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">t</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.45pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">o</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">r</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.4pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">y</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.25pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.7pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">和</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.25pt"> </span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.5pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">A</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.45pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">pp</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">l</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">i</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">c</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.35pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">a</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">t</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">i</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.4pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">on</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.45pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">C</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.4pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">on</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">t</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.35pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">e</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">x</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">t</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.25pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.65pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">有什么区别</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.75pt;margin-right:3.75pt;margin-bottom: 0cm;margin-left:3.0pt;margin-bottom:.0001pt;text-indent:-.9pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.75pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">BeanFactory</span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.75pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">可以理解为含有</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.75pt"> </span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">bean</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.75pt"> </span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">集合的工厂类</span><span style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-5.3pt">。</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -5.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">BeanFactory</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.75pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">包含了种</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.75pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">bean</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.75pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">的定义<span style="letter-spacing:-5.3pt">,</span> <span style="letter-spacing:-.05pt">以便在接收到客户端请求时将对应</span>的<span style="letter-spacing:-.9pt"> </span><span lang="EN-US">bean<span style="letter-spacing:-.9pt"> </span></span>实例化<span style="letter-spacing: -5.3pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:0cm;margin-right:1.45pt;margin-bottom: 0cm;margin-left:1.9pt;margin-bottom:.0001pt;text-indent:.2pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.75pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">BeanFactory</span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.75pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">还能在实例化对象的时生成协作类之间的关系</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-5.3pt">。</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">此举将<span lang="EN-US">bean<span style="letter-spacing:-.75pt"> </span></span>自身与<span style="letter-spacing: -.75pt"> </span><span lang="EN-US">bean<span style="letter-spacing:-.75pt"> </span></span>客 户端的配置中解放出来<span style="letter-spacing:-1.5pt">。</span><span style="letter-spacing: -5.25pt"> </span><span lang="EN-US">BeanFactory<span style="letter-spacing:-.05pt"> </span></span>还包含了<span lang="EN-US">bean<span style="letter-spacing:-.05pt"> </span></span>生命周期的控制<span style="letter-spacing:-1.5pt">,</span>调用客户端的初始 化方法(<span lang="EN-US">initialization<span style="letter-spacing:-.05pt"> </span>methods</span><span style="letter-spacing: -.4pt">)</span>和销毁方法(<span lang="EN-US">destruction methods</span><span style="letter-spacing:-.4pt">)。</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;margin-right:1.4pt;margin-bottom: 0cm;margin-left:2.05pt;margin-bottom:.0001pt;text-indent:.05pt;line-height: 114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.1pt">&gt;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.85pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">从</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">表面上看</span><span style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-5.35pt">,</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -5.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">application</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.85pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">context</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.85pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">如同</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.85pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">bean</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.85pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">factory</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.85pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">一样具有</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.85pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">bean</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.85pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">定义</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-5.35pt">、</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-5.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">bean</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.85pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">关联关</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21"> <span style="letter-spacing:-.05pt">系</span>的设置<span style="letter-spacing:-5.3pt">,</span>根据请求分发<span style="letter-spacing:-.1pt"> </span><span lang="EN-US">bean<span style="letter-spacing:-.1pt"> </span></span>的功能<span style="letter-spacing:-5.3pt">。</span>但<span style="letter-spacing:-.1pt"> </span><span lang="EN-US">application<span style="letter-spacing:-.1pt"> </span>context<span style="letter-spacing:-.1pt"> </span></span>在此基础上还提供了其他 的功能<span style="letter-spacing:-1.65pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="text-indent:2.1pt;line-height:15.6pt;mso-line-height-rule: exactly"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;position:relative;top:-3.5pt;mso-text-raise:3.5pt;letter-spacing: -.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;position:relative;top:-3.5pt;mso-text-raise:3.5pt;letter-spacing: -.45pt">&nbsp;</span><span style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative;top:-3.5pt; mso-text-raise:3.5pt;letter-spacing:-.05pt">提供了支</span><span style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative;top:-3.5pt; mso-text-raise:3.5pt">持国际化的文本消息</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.45pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">统一的</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">资源文件读取方式</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.1pt;text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.3pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.15pt">已在监</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.1pt">听器中注册的</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.3pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">bean</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.3pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">的事件</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:170%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.55pt;text-indent:1.95pt;line-height: 88%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">Sp</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">r</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">i</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">ng</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt"> </span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">Be</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">an</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.4pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">的生命周期</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.8pt;margin-right:4.6pt;margin-bottom: 0cm;margin-left:1.9pt;margin-bottom:.0001pt;text-indent:.2pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>Spring<span style="letter-spacing:-.05pt"> </span>Bean </span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21">的生命周期简单易懂<span style="letter-spacing:-4.25pt">。</span>在一个<span lang="EN-US"> bean </span>实例被初始化时<span style="letter-spacing:-4.25pt">,</span>需要执行一系列的初 始化操作以达到可用的状态<span style="letter-spacing:-2.85pt">。</span>同样的<span style="letter-spacing:-2.85pt">,</span>当一个<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">bean </span>不在被调用时需要进行相关的析构操 作<span style="letter-spacing:-3.45pt">,</span>并从<span lang="EN-US"> bean </span>容器中移除<span style="letter-spacing:-3.45pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;margin-right:1.4pt;margin-bottom: 0cm;margin-left:1.9pt;margin-bottom:.0001pt;text-indent:.2pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">Spring</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">bean</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">factory</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.25pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">负责管理在</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-1.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">spring</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-1.25pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.1pt">容器中被创建的</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">bean</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.25pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.1pt">的生命周期</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-5.4pt">。</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -5.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">Bean</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.25pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.1pt">的生命</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21"> 周期由两组回调(<span lang="EN-US">call<span style="letter-spacing:-.05pt"> </span>back</span><span style="letter-spacing: -.85pt">)</span>方法组成<span style="letter-spacing:-.85pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="text-indent:2.1pt;line-height:15.6pt;mso-line-height-rule: exactly"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;position:relative;top:-3.5pt;mso-text-raise:3.5pt">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;position:relative;top:-3.5pt;mso-text-raise: 3.5pt">初始化之后调用的回调方法<span style="letter-spacing:-2.05pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">销毁之前调用的回调方法<span style="letter-spacing: -2.05pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.1pt;text-indent:2.1pt;line-height:15.6pt; mso-line-height-rule:exactly"><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;position:relative;top:-3.5pt;mso-text-raise: 3.5pt">&gt;<span style="letter-spacing:-.05pt"> </span>Spring </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative; top:-3.5pt;mso-text-raise:3.5pt">框架提供了以下四种方式来管理<span lang="EN-US">bean </span>的生命周期事件<span style="letter-spacing:-5.25pt">:</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="text-indent:2.1pt;line-height:88%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">&gt;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-1.45pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">Initial</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">izingBean</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.45pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.1pt">和</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.45pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">DisposableBean</span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.45pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">回调接口</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.45pt;text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.35pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.15pt">针对特殊行为</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.1pt">的其他</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.35pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">Aware</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.35pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">接口</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.1pt;text-indent:2.1pt;line-height:15.6pt; mso-line-height-rule:exactly"><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;position:relative;top:-3.5pt;mso-text-raise: 3.5pt;letter-spacing:-.05pt">&gt;</span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative;top:-3.5pt; mso-text-raise:3.5pt;letter-spacing:-1.25pt">&nbsp;</span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative;top:-3.5pt; mso-text-raise:3.5pt;letter-spacing:-.05pt">Bean</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative; top:-3.5pt;mso-text-raise:3.5pt;letter-spacing:-1.25pt">&nbsp;</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;position:relative;top:-3.5pt;mso-text-raise:3.5pt;letter-spacing: -.1pt">配置文件中的</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;position:relative;top:-3.5pt;mso-text-raise:3.5pt;letter-spacing: -1.25pt">&nbsp;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative; top:-3.5pt;mso-text-raise:3.5pt;letter-spacing:-.05pt">Custom</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; position:relative;top:-3.5pt;mso-text-raise:3.5pt;letter-spacing:-1.25pt">&nbsp;</span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative;top:-3.5pt; mso-text-raise:3.5pt;letter-spacing:-.05pt">init()</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative; top:-3.5pt;mso-text-raise:3.5pt;letter-spacing:-.1pt">方法和</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative; top:-3.5pt;mso-text-raise:3.5pt;letter-spacing:-1.2pt">&nbsp;</span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative;top:-3.5pt; mso-text-raise:3.5pt;letter-spacing:-.05pt">destroy()</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;position:relative; top:-3.5pt;mso-text-raise:3.5pt;letter-spacing:-.1pt">方法</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="text-indent:2.1pt;line-height:89%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-1.35pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">@PostConstruct</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-1.35pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.1pt">和</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">@PreDestroy</span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.35pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">注解方式</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:172%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.55pt;text-indent:1.95pt;line-height: 88%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">S</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">p</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">r</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">i</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">ng</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt"> </span><span lang="EN-US" style="font-family: &quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.1pt; mso-style-textoutline-type:solid;mso-style-textoutline-fill-color:#1C1F21; mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">I</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">O</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">C</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.4pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">如何实现</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.8pt;margin-right:4.05pt;margin-bottom: 0cm;margin-left:1.9pt;margin-bottom:.0001pt;text-indent:.2pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.55pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">Spri</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">ng</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-1.55pt"> </span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.1pt">中的</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.55pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">org.springframework.beans</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.55pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.1pt">包和</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.55pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">org.springframework.context</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.55pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.1pt">包构成了</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21"> <span lang="EN-US" style="letter-spacing: -.1pt">Sprin</span><span lang="EN-US" style="letter-spacing:-.05pt">g</span><span lang="EN-US" style="letter-spacing:-1.05pt"> </span><span style="letter-spacing: -.05pt">框架</span><span style="letter-spacing:-1.05pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">IoC</span><span lang="EN-US" style="letter-spacing: -1.05pt"> </span><span style="letter-spacing:-.05pt">容器的基础</span><span style="letter-spacing:-5.35pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;margin-right:2.0pt;margin-bottom: 0cm;margin-left:1.5pt;margin-bottom:.0001pt;text-indent:.6pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>BeanFactory </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">接口提供了一个先进的配置机制<span style="letter-spacing:-1.1pt">,</span>使得任何类型的对象的配置成为可能<span style="letter-spacing: -1.1pt">。</span> <span lang="EN-US" style="letter-spacing:-.05pt">ApplicationContex</span><span lang="EN-US" style="letter-spacing:-.75pt"> </span><span style="letter-spacing: -.05pt">接口对</span><span style="letter-spacing:-.75pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">BeanFactor</span><span lang="EN-US">y<span style="letter-spacing:-.75pt"> </span></span>(是一个子接口<span style="letter-spacing: -5.3pt">)</span>进行了扩展<span style="letter-spacing:-5.3pt">,</span>在<span style="letter-spacing:-.75pt"> </span><span lang="EN-US">BeanFactory<span style="letter-spacing:-.75pt"> </span></span>的 基础上添加了其他功能<span style="letter-spacing:-3.95pt">,</span>比如与<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">Spring<span style="letter-spacing:-.05pt"> </span></span>的<span lang="EN-US"> AOP </span>更容易集成<span style="letter-spacing:-3.95pt">,</span>也提供了处理<span lang="EN-US">message&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resource<span style="letter-spacing:-.05pt"> </span></span>的机制(用于国际化<span style="letter-spacing: -2.65pt">)、</span>事件传播以及应用层的特别配置<span style="letter-spacing:-2.65pt">,</span>比如针对<span lang="EN-US"> Web </span>应用的<span lang="EN-US"> WebApplicationContext</span><span style="letter-spacing:-.1pt">。</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;margin-right:2.0pt;margin-bottom: 0cm;margin-left:1.9pt;margin-bottom:.0001pt;text-indent:.2pt;line-height:118%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.15pt"> </span>org.springframework.beans.factory.BeanFactory<span style="letter-spacing:-.15pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">是<span style="letter-spacing:-.15pt"> </span><span lang="EN-US">Spring<span style="letter-spacing:-.15pt"> </span>IoC<span style="letter-spacing:-.1pt"> </span></span>容器的具体实现<span style="letter-spacing: -5.25pt">,</span>用 来包装和管理前面提到的各种<span lang="EN-US"> bean</span><span style="letter-spacing:-4.8pt">。</span><span lang="EN-US">BeanFactory </span>接口是<span lang="EN-US"> Spring IoC </span>容器的核心接口<span style="letter-spacing:-4.8pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> </div><p> <span lang="EN-US" style="font-size:10.5pt;font-family:&quot;Arial&quot;,sans-serif; mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-ansi-language: EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA;mso-no-proof:yes"><br clear="all" style="page-break-before:always;mso-break-type:section-break"> </span> </p><div class="WordSection2"> <p class="MsoNormal" style="margin-top:9.5pt;text-indent:1.6pt;line-height:88%"><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.6pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">说说</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.2pt"> </span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.35pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">S</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.4pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">p</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">r</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">i</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.4pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">ng</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.2pt"> </span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.45pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">A</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.5pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">O</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.35pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">P</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.75pt;margin-right:17.75pt;margin-bottom: 0cm;margin-left:2.0pt;margin-bottom:.0001pt;text-indent:.1pt;line-height:117%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.1pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">面向切面编程<span style="letter-spacing:-.2pt">,</span>在我们的应用中<span style="letter-spacing:-.2pt">,</span>经常需要做一些事情<span style="letter-spacing:-.2pt">,</span>但是这些事情与核心业务无 关<span style="letter-spacing:-1.1pt">,</span>比如<span style="letter-spacing: -1.1pt">,</span>要记录所有<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">update*</span>方法的执行时间时间<span style="letter-spacing:-1.1pt">,</span>操作人等等信息<span style="letter-spacing:-1.1pt">,</span>记录到日志<span style="letter-spacing:-1.1pt">,</span> <span lang="EN-US" style="letter-spacing:-.05pt">&gt;</span><span lang="EN-US" style="letter-spacing:-.55pt"> </span><span style="letter-spacing:-.05pt">通过</span><span style="letter-spacing:-.55pt"> </span><span lang="EN-US" style="letter-spacing: -.05pt">spring</span><span lang="EN-US" style="letter-spacing:-.55pt"> </span><span style="letter-spacing:-.05pt">的</span><span style="letter-spacing:-.55pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">AOP</span><span lang="EN-US" style="letter-spacing:-.55pt"> </span><span style="letter-spacing:-.05pt">技术</span><span style="letter-spacing:-5.3pt">,</span><span style="letter-spacing:-.05pt">就可以在不修改</span><span style="letter-spacing:-.55pt"> </span><span lang="EN-US" style="letter-spacing: -.05pt">upd</span><span lang="EN-US">ate*</span>的代码的情况下完成该需求<span style="letter-spacing:-5.3pt">。</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:132%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="line-height:132%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.5pt;text-indent:1.95pt;line-height:88%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">Sp</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">r</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">i</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">ng</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt"> </span><span lang="EN-US" style="font-family: &quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.35pt; mso-style-textoutline-type:solid;mso-style-textoutline-fill-color:#1C1F21; mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">AO</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">P</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.45pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">实现原理</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.8pt;margin-right:1.4pt;margin-bottom: 0cm;margin-left:1.95pt;margin-bottom:.0001pt;text-indent:.15pt;line-height: 114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>Spring<span style="letter-spacing:-.05pt"> </span>AOP<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">中的动态代理主要有两种方式<span style="letter-spacing:-5.25pt">, </span><span lang="EN-US">JDK </span>动态代理和<span lang="EN-US">CGLIB </span>动态代理<span style="letter-spacing:-5.25pt">。 </span><span lang="EN-US">JDK </span>动态代 理通过反射来接收被代理的类<span style="letter-spacing:-1.55pt">,</span>并且要求被代理的类必须实现一个接口<span style="letter-spacing:-1.55pt">。</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">JDK<span style="letter-spacing:-.1pt"> </span></span>动态代理的 <span style="letter-spacing:-.1pt">核心是</span><span style="letter-spacing:-1.15pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">InvocationHandler</span><span lang="EN-US" style="letter-spacing:-1.15pt"> </span><span style="letter-spacing: -.05pt">接口和</span><span style="letter-spacing:-1.15pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">Proxy</span><span lang="EN-US" style="letter-spacing:-1.15pt"> </span><span style="letter-spacing:-.05pt">类</span><span style="letter-spacing:-5.4pt">。</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.15pt;margin-right:1.45pt;margin-bottom: 0cm;margin-left:1.85pt;margin-bottom:.0001pt;text-indent:.25pt;line-height: 116%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">如果目标类没有实现接口<span style="letter-spacing:-5.25pt">,</span>那么<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">Spring<span style="letter-spacing:-.05pt"> </span>AOP </span>会选择使用<span lang="EN-US">CGLIB </span>来动态代理目标类<span style="letter-spacing:-5.25pt">。 </span><span lang="EN-US">CGLIB </span>(<span lang="EN-US">Code<span style="letter-spacing:-.1pt"> </span>Generation<span style="letter-spacing:-.05pt"> </span>Library</span><span style="letter-spacing:-.25pt">),</span>是一个代码生成的类库<span style="letter-spacing: -.25pt">,</span>可以在运行时动态的生成某个类 的子类<span style="letter-spacing:-1.25pt">,</span>注意<span style="letter-spacing:-1.25pt">,</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">CGLIB<span style="letter-spacing:-.1pt"> </span></span>是通过继承的方式做的动态代理<span style="letter-spacing:-1.25pt">,</span>因此如果某个类被标记为<span style="letter-spacing: -.05pt"> </span><span lang="EN-US">final</span><span style="letter-spacing:-1.25pt">,</span> <span style="letter-spacing:-.05pt">那么它是无法使用</span><span style="letter-spacing: -.6pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">C</span><span lang="EN-US">GLIB<span style="letter-spacing:-.6pt"> </span></span>做动态代理的<span style="letter-spacing:-5.3pt">。</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:4.95pt;text-indent:1.6pt;line-height:88%"><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.45pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">动态代理(</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21"> <span lang="EN-US" style="letter-spacing:.25pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">c</span><span lang="EN-US" style="letter-spacing:.3pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">g</span><span lang="EN-US" style="letter-spacing:.15pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">li</span><span lang="EN-US" style="letter-spacing:.3pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">b</span><span lang="EN-US" style="letter-spacing:.15pt"> </span><span style="letter-spacing: .4pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color:#1C1F21; mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">与</span><span style="letter-spacing:.15pt"> <span lang="EN-US">J</span></span><span lang="EN-US" style="letter-spacing:.3pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">D</span><span lang="EN-US" style="letter-spacing:.25pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">K</span><span style="letter-spacing:.45pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">)</span></span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.7pt;margin-right:1.45pt;margin-bottom: 0cm;margin-left:1.8pt;margin-bottom:.0001pt;text-indent:.3pt;line-height:117%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.1pt"> </span>JDK<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">动态代理类和委托类需要都实现同一个接口<span style="letter-spacing:-5.25pt">。</span>也就是说只有实现了某个接口的类可以 使用<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">Java </span>动态代理机制<span style="letter-spacing:-2.8pt">。</span>但是<span style="letter-spacing:-2.8pt">,</span>事实上使用中并不是遇到的所有类都会给你实现一个接<span lang="EN-US">&nbsp; </span>口<span style="letter-spacing:-1.4pt">。</span>因此<span style="letter-spacing:-1.4pt">,</span>对于没有实现接口的类<span style="letter-spacing:-1.4pt">,</span>就不能使用该机制<span style="letter-spacing:-1.4pt">。</span>而<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">CGLIB </span>则可以实现对类的动态 代理<span style="letter-spacing:-1.3pt">。</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:132%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.5pt;text-indent:1.95pt;line-height:88%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">Sp</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">ri</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">n</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">g</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.35pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">事务实现方式</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.75pt;text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>1</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.0pt">、</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">编码方式</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.15pt;margin-right:24.5pt;margin-bottom: 0cm;margin-left:2.1pt;margin-bottom:.0001pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">所谓编程式事务指的是通过编码方式实现事务<span style="letter-spacing:-3.7pt">,</span>即类似于<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">JDBC </span>编程实现事务管理<span style="letter-spacing:-3.7pt">。</span><span lang="EN-US"> &gt;<span style="letter-spacing:-.05pt"> </span>2</span><span style="letter-spacing:-1.05pt">、</span>声明式事务管理方式</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:0cm;margin-right:7.25pt;margin-bottom: 0cm;margin-left:1.75pt;margin-bottom:.0001pt;text-indent:.35pt;line-height: 119%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">声明式事务管理又有两种实现方式<span style="letter-spacing:-2.95pt">:</span>基于<span lang="EN-US"> xml </span>配置文件的方式<span style="letter-spacing:-2.95pt">;</span>另一个实在业务方法上 进行<span lang="EN-US">@Transaction<span style="letter-spacing:-.05pt"> </span></span>注解<span style="letter-spacing: -2.9pt">,</span>将事务规则应用到业务逻辑中</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:130%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="line-height:131%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.55pt;text-indent:1.95pt;line-height: 88%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">Sp</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">ri</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">n</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">g</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.35pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">事务底层原理</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.8pt;text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt; a</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.7pt">、</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">划分处理单元<span lang="EN-US">——IOC</span></span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.1pt;margin-right:4.05pt;margin-bottom: 0cm;margin-left:1.95pt;margin-bottom:.0001pt;text-indent:.15pt;line-height: 114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.05pt">&gt;</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">由于</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.65pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">spring</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.65pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">解决的问题是对</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21">单个数据库进行局部事务处理的<span style="letter-spacing:-5.3pt">,</span>具体的实现首相用<span style="letter-spacing:-.65pt"> </span><span lang="EN-US">spring </span><span style="letter-spacing:-.05pt">中的</span><span style="letter-spacing:-1.0pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">IOC</span><span lang="EN-US" style="letter-spacing:-1.0pt"> </span><span style="letter-spacing:-.05pt">划分了事务处理单元</span><span style="letter-spacing:-5.3pt">。</span><span style="letter-spacing:-.05pt">并且将对事务的各种配置放到了</span><span style="letter-spacing:-1.0pt"> </span><span lang="EN-US" style="letter-spacing: -.05pt">ioc</span><span lang="EN-US" style="letter-spacing:-1.0pt"> </span><span style="letter-spacing:-.05pt">容器中(</span>设置事务管 理器<span style="letter-spacing: -.65pt">,</span>设置事务的传播特性及隔离机制<span style="letter-spacing:-.65pt">)。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>b</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-3.25pt">、</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">AOP </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">拦截需要进行事务处理的类</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.15pt;margin-right:2.0pt;margin-bottom: 0cm;margin-left:1.9pt;margin-bottom:.0001pt;text-indent:.15pt;line-height:116%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.6pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">Spring</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.6pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">事务处理模块是通过</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.6pt"> </span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">AO</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">P<span style="letter-spacing:-.6pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">功能来实现声明式事务处理的<span style="letter-spacing: -5.3pt">,</span>具体操作(比如事务实 行的配置和读取<span style="letter-spacing:-2.75pt">,</span>事务对象的抽象<span style="letter-spacing:-2.75pt">),</span>用<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">TransactionProxyFactoryBean<span style="letter-spacing:-.05pt"> </span></span>接口来使用<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">AOP </span>功能<span style="letter-spacing:-3.65pt">,</span>生成<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">proxy </span>代理对象<span style="letter-spacing:-3.65pt">,</span>通过<span lang="EN-US"> TransactionInterceptor </span>完成对代理方法的拦截<span style="letter-spacing: -3.65pt">,</span>将事 务处理的功能编织到拦截的方法中<span style="letter-spacing:-5.3pt">。</span>读取<span style="letter-spacing:-.1pt"> </span><span lang="EN-US">ioc<span style="letter-spacing:-.1pt"> </span></span>容器事务配置属性<span style="letter-spacing: -5.3pt">,</span>转化为<span style="letter-spacing:-.1pt"> </span><span lang="EN-US">spring<span style="letter-spacing:-.1pt"> </span></span>事务处理</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> </div><p> <span lang="EN-US" style="font-size:10.5pt;font-family:&quot;Arial&quot;,sans-serif; mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-ansi-language: EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA;mso-no-proof:yes"><br clear="all" style="page-break-before:always;mso-break-type:section-break"> </span> </p><div class="WordSection3"> <p class="MsoNormal" style="margin-top:3.05pt;text-indent:2.4pt;line-height:15.6pt; mso-line-height-rule:exactly"><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;position:relative;top:-3.5pt;mso-text-raise:3.5pt">需要的内部数据结构(<span lang="EN-US">TransactionAttributeSourceAdvisor</span><span style="letter-spacing: -.75pt">)</span><span style="letter-spacing:-.7pt">,</span>转化为</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="text-indent:1.7pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">TransactionAttribute </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">表示的数据对象<span style="letter-spacing:-4.2pt">。</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.05pt;text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.1pt"> </span>c</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.3pt">、</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">对事物处理实现(事务的生成<span style="letter-spacing:-.25pt">、</span>提交<span style="letter-spacing:-.25pt">、</span>回滚<span style="letter-spacing:-.25pt">、</span>挂起<span style="letter-spacing:-.25pt">)</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.15pt;margin-right:1.45pt;margin-bottom: 0cm;margin-left:1.65pt;margin-bottom:.0001pt;text-indent:.45pt;line-height: 114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>spring </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">委托给具体的事务处理器实现<span style="letter-spacing:-1.65pt">。</span>实现了一个抽象和适配<span style="letter-spacing: -1.65pt">。</span>适配的具体事务处理<span lang="EN-US">&nbsp; </span>器<span style="letter-spacing:-2.7pt">:</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">DataSource<span style="letter-spacing:-.05pt"> </span></span>数据源支持<span style="letter-spacing: -2.7pt">、</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">hibernate </span>数据源事务处理支持<span style="letter-spacing:-2.7pt">、</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">JDO </span>数据源事务处理支<span lang="EN-US">&nbsp;&nbsp; </span>持<span style="letter-spacing:-.95pt">,</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">JPA</span><span style="letter-spacing:-.95pt">、</span><span lang="EN-US">JTA<span style="letter-spacing:-.05pt"> </span></span>数据源事务处理支持<span style="letter-spacing:-.95pt">。</span>这些支持都是通过设计<span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PlatformTransactionManager</span>、<span lang="EN-US">AbstractPlatforTransaction </span>一系列事务处理的支持。<span style="letter-spacing:-4.95pt"> </span>为 常用数据源支持提供了一系列的<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">TransactionManager</span><span style="letter-spacing:-2.85pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt; d</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.0pt">、</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">结合</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.1pt;margin-right:6.1pt;margin-bottom: 0cm;margin-left:1.7pt;margin-bottom:.0001pt;text-indent:.4pt;line-height:118%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.6pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">PlatformTransacti</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">onManager<span style="letter-spacing:-.6pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">实现了<span style="letter-spacing:-.6pt"> </span><span lang="EN-US">TransactionInterception<span style="letter-spacing:-.6pt"> </span></span>接口<span style="letter-spacing:-5.3pt">,</span>让其与<span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TransactionProxyFactoryBean </span>结合起来<span style="letter-spacing:-4.85pt">,</span>形成一个 <span lang="EN-US">Spring </span>声明式事务处理的设计体系<span style="letter-spacing:-4.85pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:141%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="line-height:141%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.5pt;text-indent:1.6pt;line-height:76%"><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:-.05pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">如何自定</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">义注解实现功能</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.85pt;margin-right:3.5pt;margin-bottom: 0cm;margin-left:2.1pt;margin-bottom:.0001pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">创建自定义注解和创建一个接口相似<span style="letter-spacing: -3.7pt">,</span>但是注解的<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">interface </span>关键字需要以<span lang="EN-US">@</span>符号开头<span style="letter-spacing:-3.7pt">。</span><span lang="EN-US"> &gt;<span style="letter-spacing:-.05pt"> </span></span>注解方法不能带有参数<span style="letter-spacing: -2.85pt">;</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;margin-right:1.45pt;margin-bottom: 0cm;margin-left:1.9pt;margin-bottom:.0001pt;text-indent:.15pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt; </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">注解方法返回值类型限定为<span style="letter-spacing:-1.35pt">:</span>基本类型<span style="letter-spacing:-1.35pt">、</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">String</span><span style="letter-spacing:-1.35pt">、</span><span lang="EN-US">Enums</span><span style="letter-spacing:-1.35pt">、</span><span lang="EN-US">Annotation </span>或者是这些类型的 数组<span style="letter-spacing:-2.0pt">;</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;text-indent:2.1pt;line-height:90%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">注解方法可以有默认值<span style="letter-spacing: -2.85pt">;</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.15pt;text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">注解本身能够包含元注解<span style="letter-spacing: -1.05pt">,</span>元注解被用来注解其它注解<span style="letter-spacing:-1.05pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:171%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.5pt;text-indent:1.95pt;line-height:88%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">Sp</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">r</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">i</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">ng</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt"> </span><span lang="EN-US" style="font-family: &quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.45pt; mso-style-textoutline-type:solid;mso-style-textoutline-fill-color:#1C1F21; mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">M</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.35pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">V</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">C</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.4pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">运行流程</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.8pt;margin-right:2.0pt;margin-bottom: 0cm;margin-left:2.2pt;margin-bottom:.0001pt;text-indent:-.1pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.05pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">1.spring</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.05pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">mvc</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.05pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">将所有的请求都提交给</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-1.05pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">DispatcherSer</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21">vlet,</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21">它会委托应用系统的其他模块 负责对请求<span style="letter-spacing:-.05pt"> </span>进行真正的处理工作<span style="letter-spacing:-2.15pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;margin-right:15.1pt;margin-bottom: 0cm;margin-left:2.1pt;margin-bottom:.0001pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-1.45pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">2.DispatcherServlet</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.45pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">查询一个或多个</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-1.45pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">HandlerMapping,</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">找到处理请求的</span><span style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.45pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">Control</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">ler. <span style="letter-spacing:-.05pt">&gt;</span><span style="letter-spacing:-1.35pt"> </span><span style="letter-spacing:-.05pt">3.DispatcherServlet</span><span style="letter-spacing:-1.35pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">请请求提交到目标</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.35pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">Controller</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;text-indent:2.1pt;line-height:90%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt; 4.Controller </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">进行业务逻辑处理后<span style="letter-spacing:-.7pt">,</span>会返回一个<span lang="EN-US">ModelAndView</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.15pt;margin-right:4.6pt;margin-bottom: 0cm;margin-left:2.65pt;margin-bottom:.0001pt;text-indent:-.55pt;line-height: 114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.1pt">&gt;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.6pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.1pt">5.Dispath</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">cher</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-1.6pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.1pt">查询一个或多个</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.6pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">ViewResolver</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.6pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">视图解析器</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">,</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">找到</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-1.6pt"> </span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">ModelAndView</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-1.6pt"> </span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.1pt">对象指定</span><span style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21"> <span style="letter-spacing:-.25pt">的</span><span style="letter-spacing:-.2pt">视图对象</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>6.</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">视图对象负责渲染返回给客户端<span style="letter-spacing: -2.1pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.55pt;text-indent:1.95pt;line-height: 88%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">Sp</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">r</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">i</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">ng</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt"> </span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.45pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">M</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.35pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">V</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">C</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.4pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">启动流程</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.85pt;margin-right:1.4pt;margin-bottom: 0cm;margin-left:2.1pt;margin-bottom:.0001pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">&gt;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.85pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.1pt">在</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.85pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.1pt">we</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">b.xml</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.85pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">文件中给</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.85pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">Spring</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.85pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">MVC</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.85pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">的</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.85pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">Servlet</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.85pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">配置了</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.85pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">load-on-startup,</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">所以程序启动的</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21"> &gt; </span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21">时候会初始化<span lang="EN-US"> Spring MVC</span><span style="letter-spacing:-.7pt">,</span>在<span lang="EN-US"> HttpServletBean </span>中将配置的<span lang="EN-US"> contextConfigLocation &gt;<span style="letter-spacing:-.05pt"> </span></span>属性设置到<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">Servlet<span style="letter-spacing:-.05pt"> </span></span>中<span style="letter-spacing:-5.25pt">,</span>然后在<span lang="EN-US"> FrameworkServlet </span>中创建了<span lang="EN-US"> WebApplicationContext, <span style="letter-spacing:-.1pt">&gt;</span><span style="letter-spacing:-1.85pt"> </span><span style="letter-spacing:-.1pt">DispatcherServlet</span><span style="letter-spacing:-1.85pt"> </span></span><span style="letter-spacing:-.2pt">根据</span><span style="letter-spacing:-1.85pt"> </span><span lang="EN-US" style="letter-spacing: -.1pt">contextConfigLocatio</span><span lang="EN-US" style="letter-spacing:-.05pt">n</span><span lang="EN-US" style="letter-spacing:-1.85pt"> </span><span style="letter-spacing: -.15pt">配置的</span><span style="letter-spacing:-1.85pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">classpath</span><span lang="EN-US" style="letter-spacing:-1.85pt"> </span><span style="letter-spacing:-.15pt">下的</span><span style="letter-spacing:-1.85pt"> </span><span lang="EN-US" style="letter-spacing: -.05pt">xml</span><span lang="EN-US" style="letter-spacing:-1.85pt"> </span><span style="letter-spacing:-.15pt">文件初始化</span> 了</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="text-indent:2.1pt;line-height:88%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>Spring MVC </span><span style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21">总的组件<span style="letter-spacing:-1.75pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> </div><p> <span lang="EN-US" style="font-size:10.5pt;font-family:&quot;Arial&quot;,sans-serif; mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-ansi-language: EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA;mso-no-proof:yes"><br clear="all" style="page-break-before:always;mso-break-type:section-break"> </span> </p><div class="WordSection4"> <p class="MsoNormal" style="margin-top:9.5pt;text-indent:1.95pt;line-height:88%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">Sp</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">r</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.1pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">i</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">ng</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.35pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">的</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.3pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">单例实现原理</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.7pt;margin-right:1.4pt;margin-bottom: 0cm;margin-left:1.75pt;margin-bottom:.0001pt;text-indent:.35pt;line-height: 118%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.95pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">Spring</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.95pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">对</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.95pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">Bean</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.95pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">实例的创建是采用单例注册表的方式进行实</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">现的<span style="letter-spacing:-5.3pt">,</span>而这个注册表的缓存是<span lang="EN-US"> ConcurrentHashMap<span style="letter-spacing:-.05pt"> </span></span>对象<span style="letter-spacing:-1.2pt">。</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:135%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.5pt;text-indent:1.95pt;line-height:88%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">S</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">p</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.1pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">ri</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">n</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">g</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.1pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">框架</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">中用到了哪些设计模式</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.7pt;text-indent:2.1pt;line-height:89%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.35pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">代理模式<span lang="EN-US">—</span>在</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.35pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">AO</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">P<span style="letter-spacing:-.35pt"> </span></span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">和<span lang="EN-US">remoting<span style="letter-spacing:-.35pt"> </span></span>中被用的比较多<span style="letter-spacing: -5.3pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.4pt;text-indent:2.1pt;line-height:89%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.05pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">单例模式<span lang="EN-US">—</span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">在</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.05pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">spring</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.05pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.05pt">配置文件中定义的</span><span style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.05pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">bean</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.05pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">默认为单例模式</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-5.35pt">。</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.5pt;margin-right:59.75pt;margin-bottom: 0cm;margin-left:1.8pt;margin-bottom:.0001pt;text-indent:.3pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt; </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">模板方法<span lang="EN-US">—</span>用来解决代码重复的问题。比如<span lang="EN-US">. RestTemplate,<span style="letter-spacing:-.7pt"> </span>JmsTemplate, JpaTemplate</span><span style="letter-spacing:-.4pt">。</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;text-indent:2.1pt;line-height:88%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">前端控制器<span lang="EN-US">—Spring </span>提供了<span lang="EN-US">DispatcherServlet </span>来对请求进行分发<span style="letter-spacing:-4.6pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.45pt;margin-right:1.4pt;margin-bottom: 0cm;margin-left:1.9pt;margin-bottom:.0001pt;text-indent:.2pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.25pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">视图帮助<span lang="EN-US">(View</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.1pt">Hel</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">per</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-1.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">)—Spring</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-1.25pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">提供了一系列的</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.25pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">JSP</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.25pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.05pt">标签</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-5.35pt">,</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">高效宏来辅助将分散的代码</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21"> 整合在视图里<span style="letter-spacing:-1.7pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:0cm;margin-right:66.5pt;margin-bottom: 0cm;margin-left:2.1pt;margin-bottom:.0001pt;line-height:118%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.35pt"> </span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">依赖注入<span lang="EN-US">—</span>贯穿于</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.35pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">BeanFactory<span style="letter-spacing:-.35pt"> </span>/<span style="letter-spacing:-.35pt"> </span>ApplicationContext<span style="letter-spacing:-.35pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">接口的核心理念<span style="letter-spacing:-5.3pt">。</span><span lang="EN-US"> &gt;<span style="letter-spacing:-.05pt"> </span></span>工厂模式<span lang="EN-US">—BeanFactory </span>用来创建对象的实例<span style="letter-spacing:-4.6pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:107%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="line-height:107%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:7.15pt;text-indent:3.05pt;line-height: 87%"><span lang="EN-US" style="font-size:16.5pt;line-height:87%;font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:-.55pt">N</span><span lang="EN-US" style="font-size:16.5pt;line-height:87%;font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:-.4pt">e</span><span lang="EN-US" style="font-size:16.5pt;line-height:87%;font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:-.2pt">tt</span><span lang="EN-US" style="font-size:16.5pt;line-height:87%;font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:-.3pt">y</span><span lang="EN-US" style="font-size:16.5pt;line-height:87%;font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:12.05pt;text-indent:1.6pt;line-height: 76%"><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.5pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">为什么选择</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.2pt"> </span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.35pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">N</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">e</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">tt</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">y</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.85pt;text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>1)<span style="letter-spacing:-5.25pt"> </span>API<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">使用简单<span style="letter-spacing:-.1pt">,</span>开发门槛低<span style="letter-spacing:-.1pt">;</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.1pt;text-indent:2.1pt;line-height:91%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt; 2)<span style="letter-spacing:-3.0pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">功能强大<span style="letter-spacing:-.05pt">,</span>预置了多种编解码功能,支持多种主流协议;</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:3.15pt;margin-right:59.55pt;margin-bottom: 0cm;margin-left:2.1pt;margin-bottom:.0001pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt; 3)<span style="letter-spacing:-3.15pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">定制能力强,可以通过<span lang="EN-US"> ChannelHandler </span>对通信框架进行灵活的扩展;<span lang="EN-US"> &gt;<span style="letter-spacing:-.05pt"> </span>4)<span style="letter-spacing:-5.25pt"> </span></span>性能高<span style="letter-spacing:-1.9pt">,</span>通过与其它业界主流的<span style="letter-spacing: -.05pt"> </span><span lang="EN-US">NIO </span>框架对比<span style="letter-spacing: -1.9pt">,</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">Netty </span>的综合性能最优<span style="letter-spacing:-1.9pt">;</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;margin-right:7.75pt;margin-bottom: 0cm;margin-left:1.5pt;margin-bottom:.0001pt;text-indent:.6pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>5)<span style="letter-spacing:-5.25pt"> </span></span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">成熟<span style="letter-spacing:-.4pt">、</span>稳定<span style="letter-spacing:-.4pt">,</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">Netty </span>修复了已经发现的所有<span lang="EN-US"> JDK NIO BUG</span><span style="letter-spacing:-.4pt">,</span>业务开发人员不需要再为 <span lang="EN-US" style="letter-spacing:-.1pt">NIO</span><span lang="EN-US" style="letter-spacing:-1.05pt"> </span><span style="letter-spacing:-.15pt">的</span><span style="letter-spacing:-1.05pt"> </span><span lang="EN-US" style="letter-spacing: -.1pt">BUG</span><span lang="EN-US" style="letter-spacing:-1.05pt"> </span><span style="letter-spacing:-.15pt">而</span><span style="letter-spacing:-.1pt">烦恼</span><span style="letter-spacing:-5.45pt">;</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:0cm;margin-right:2.0pt;margin-bottom:0cm; margin-left:1.85pt;margin-bottom:.0001pt;text-indent:.25pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>6)<span style="letter-spacing:-5.25pt"> </span></span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">社区活跃<span style="letter-spacing:-.15pt">,</span>版本迭代周期短<span style="letter-spacing:-.15pt">,</span>发现的<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">BUG </span>可以被及时修复<span style="letter-spacing:-.15pt">,</span>同时<span style="letter-spacing:-.15pt">,</span>更多的新功能会被 加入<span style="letter-spacing:-1.95pt">;</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;margin-right:3.5pt;margin-bottom: 0cm;margin-left:1.9pt;margin-bottom:.0001pt;text-indent:.15pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt; 7)<span style="letter-spacing:-2.2pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">经历了大规模的商业应用考验<span style="letter-spacing: -.05pt">,</span>质量已经得到验证。在互联网、大数据、网络游戏、 企业应用<span style="letter-spacing:-.25pt">、</span>电信软件等众多行业得到成功商用<span style="letter-spacing:-.25pt">,</span>证明了它可以完全满足不同行业的商业应 用<span style="letter-spacing:-1.05pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;text-indent:2.1pt;line-height:89%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">正是因为这些优点<span style="letter-spacing: -4.9pt">,</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">Netty </span>逐渐成为<span lang="EN-US"> Java NIO </span>编程的首选框架<span style="letter-spacing: -4.9pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:190%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.5pt;text-indent:1.6pt;line-height:76%"><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.05pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">说说业务中,</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21"> <span lang="EN-US" style="letter-spacing:.05pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">Netty</span><span lang="EN-US" style="letter-spacing:.05pt"> </span><span style="letter-spacing: .05pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color:#1C1F21; mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">的使用场景</span></span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.9pt;margin-right:4.3pt;margin-bottom: 0cm;margin-left:1.5pt;margin-bottom:.0001pt;text-indent:.6pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">构建高性能<span style="letter-spacing:-2.7pt">、</span>低时延的各种<span lang="EN-US"> Java </span>中间件<span style="letter-spacing:-2.7pt">,</span>例如<span lang="EN-US"> MQ</span><span style="letter-spacing:-2.7pt">、</span>分布式服务框架<span style="letter-spacing:-2.7pt">、</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">ESB </span>消息总线等<span style="letter-spacing:-2.7pt">,</span><span lang="EN-US"> Netty<span style="letter-spacing:-.05pt"> </span></span>主要作为基础通信框架提供高性能<span style="letter-spacing:-2.5pt">、</span>低时延的通信服务<span style="letter-spacing:-2.5pt">;</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.05pt;margin-right:38.75pt;margin-bottom: 0cm;margin-left:1.5pt;margin-bottom:.0001pt;text-indent:.6pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span></span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21">公有或者私有协议栈的基础通信框架<span style="letter-spacing: -2.95pt">,</span>例如可以基于<span lang="EN-US"> Netty </span>构建异步<span style="letter-spacing:-2.95pt">、</span>高性能的<span lang="EN-US"> WebSocket<span style="letter-spacing:-.05pt"> </span></span>协议栈<span style="letter-spacing: -4.4pt">;</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:.1pt;margin-right:1.45pt;margin-bottom: 0cm;margin-left:1.95pt;margin-bottom:.0001pt;text-indent:.15pt;line-height: 119%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21">&gt; </span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21">各领域应用<span style="letter-spacing:-1.8pt">,</span>例如大数据<span style="letter-spacing:-1.8pt">、</span>游戏等<span style="letter-spacing:-1.8pt">,</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">Netty </span>作为高性能的通信框架用于内部各模块的数据 分发<span style="letter-spacing:-.7pt">、</span>传输和汇总等<span style="letter-spacing: -.65pt">,</span>实现模块之间高性能通信<span style="letter-spacing:-.65pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> </div><p> <span lang="EN-US" style="font-size:10.5pt;font-family:&quot;Arial&quot;,sans-serif; mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-ansi-language: EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA;mso-no-proof:yes"><br clear="all" style="page-break-before:always;mso-break-type:section-break"> </span> </p><div class="WordSection5"> <p class="MsoNormal"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.5pt;text-indent:1.55pt;line-height:88%"><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.8pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">原生的</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.35pt"> </span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.65pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">N</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">I</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.65pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">O</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.35pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.8pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">在</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.35pt"> <span lang="EN-US">J</span></span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.6pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">D</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.5pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">K</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.35pt"> </span><span lang="EN-US" style="font-family: &quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.5pt; mso-style-textoutline-type:solid;mso-style-textoutline-fill-color:#1C1F21; mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">1</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">.</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.5pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">7</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.35pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.8pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">版本存在</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.35pt"> </span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.45pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">e</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.5pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">po</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">ll</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.3pt"> </span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.5pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">bug</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.7pt;margin-right:1.4pt;margin-bottom: 0cm;margin-left:1.9pt;margin-bottom:.0001pt;text-indent:.2pt;line-height:117%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.1pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.15pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.15pt">它会导致</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-1.15pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">Selecto</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">r</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.15pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.1pt">空轮询</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-5.4pt">,</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">最终导致</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-1.15pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">CPU</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-1.15pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">100%</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-5.4pt">。</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.1pt">官方声称在</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.15pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">JDK</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.15pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">1.6</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -1.15pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.1pt">版本的</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.15pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">update18</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-1.15pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.1pt">修</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21"> 复了该问题<span style="letter-spacing:-5.25pt">,</span>但是直到<span style="letter-spacing: -.1pt"> </span><span lang="EN-US">JDK<span style="letter-spacing:-.1pt"> </span>1.7<span style="letter-spacing:-.1pt"> </span></span>版本该问题仍旧存在<span style="letter-spacing: -5.25pt">,</span>只不过该<span style="letter-spacing:-.1pt"> </span><span lang="EN-US">BUG<span style="letter-spacing:-.1pt"> </span></span>发生概率降低了一些 而已<span style="letter-spacing:-.95pt">,</span>它并没有得到根本性解决<span style="letter-spacing: -.9pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family: 宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:133%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.5pt;text-indent:1.55pt;line-height:95%"><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.35pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">什么</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">是</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.15pt"> <span lang="EN-US">T</span></span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">C</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">P</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">粘包</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.1pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">/</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">拆包</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:7.4pt;margin-right:4.6pt;margin-bottom: 0cm;margin-left:2.0pt;margin-bottom:.0001pt;text-indent:.1pt;line-height:118%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.05pt"> </span>1</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-2.45pt">、</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">要发送的数据大于<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">TCP<span style="letter-spacing:-.05pt"> </span></span>发送缓冲区剩余空间大小<span style="letter-spacing: -2.45pt">,</span>将会发生拆包<span style="letter-spacing:-2.45pt">。</span><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt; 2</span><span style="letter-spacing:-3.15pt">、</span>待发送数据大于<span lang="EN-US"> MSS </span>(最大报文长度<span style="letter-spacing:-3.15pt">),</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">TCP </span>在传输前将进行拆包<span style="letter-spacing:-3.15pt">。</span><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<span style="letter-spacing:-.05pt"> </span>3</span><span style="letter-spacing:-4.2pt">、</span>要发送的数据小于<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">TCP </span>发送缓冲区的大小<span style="letter-spacing:-4.2pt">,</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">TCP </span>将多次写入缓冲区的数据一次发送出 去<span style="letter-spacing:-1.05pt">,</span>将会发生粘包<span style="letter-spacing:-1.05pt">。</span><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<span style="letter-spacing:-.1pt"> </span>4</span><span style="letter-spacing:-.65pt">、</span>接收数据端的应用层没有及时读取接收缓冲区中的数据<span style="letter-spacing:-.65pt">,</span>将发生粘包<span style="letter-spacing:-.65pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:122%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.5pt;text-indent:1.6pt;line-height:95%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.1pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">TCP</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.1pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.05pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">粘包<span lang="EN-US">/</span>拆包的解决办法</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:7.35pt;margin-right:2.0pt;margin-bottom: 0cm;margin-left:1.8pt;margin-bottom:.0001pt;text-indent:.3pt;line-height:116%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt;<span style="letter-spacing:-.1pt"> </span>1</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.4pt">、</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">发送端给每个数据包添加包首部<span style="letter-spacing:-.4pt">,</span>首部中应该至少包含数据包的长度<span style="letter-spacing: -.4pt">,</span>这样接收端在 接收到数据后<span style="letter-spacing:-.65pt">,</span>通过读取包首部的长度字段<span style="letter-spacing:-.65pt">,</span>便知道每一个数据包的实际长度了<span style="letter-spacing: -.6pt">。</span><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<span style="letter-spacing:-.05pt"> </span>2</span><span style="letter-spacing:-1.85pt">、</span>发送端将每个数据包封装为固定长度(不够的可以通过补<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">0 </span>填充<span style="letter-spacing:-1.85pt">),</span>这样接收端每次 从接收缓冲区中读取固定长度的数据就自然而然的把每个数据包拆分开来<span style="letter-spacing:-1.9pt">。</span><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;<span style="letter-spacing: -.1pt"> </span>3</span><span style="letter-spacing:-.2pt">、</span>可以在数据包之间设置边界<span style="letter-spacing:-.2pt">,</span>如添加特殊符号<span style="letter-spacing:-.2pt">,</span>这样<span style="letter-spacing:-.2pt">,</span>接收端通过这个边界就可以将 不同的数据包拆分开<span style="letter-spacing:-1.75pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:151%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.55pt;text-indent:2.35pt;line-height: 75%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.4pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">N</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">e</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.2pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">tt</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">y</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.4pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">线程模型</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:9.0pt;margin-right:1.45pt;margin-bottom: 0cm;margin-left:1.8pt;margin-bottom:.0001pt;text-indent:.3pt;line-height:116%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt; </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">首先<span style="letter-spacing:-2.7pt">,</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">Netty </span>使用<span lang="EN-US">EventLoop </span>来处理连接上的读写事件<span style="letter-spacing:-2.7pt">,</span>而一个连接上的所有请求都保证 <span style="letter-spacing: -.05pt">在一个</span><span style="letter-spacing:-.5pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">EventLoop</span><span lang="EN-US" style="letter-spacing:-.5pt"> </span><span style="letter-spacing:-.05pt">中被处理</span><span style="letter-spacing:-5.3pt">,</span><span style="letter-spacing:-.05pt">一</span>个<span style="letter-spacing:-.5pt"> </span><span lang="EN-US">EventLoop<span style="letter-spacing:-.5pt"> </span></span>中只有一个<span style="letter-spacing: -.5pt"> </span><span lang="EN-US">Thread</span><span style="letter-spacing:-5.3pt">,</span>所以也就实现了一个连 接上的所有事件只会在一个线程中被执行<span style="letter-spacing:-4.35pt">。</span>一个<span lang="EN-US"> EventLoopGroup </span>包含多个<span lang="EN-US"> EventLoop</span><span style="letter-spacing:-4.35pt">,</span>可 <span style="letter-spacing:-.1pt">以把一个</span><span style="letter-spacing:-1.3pt"> </span><span lang="EN-US" style="letter-spacing: -.1pt">Even</span><span lang="EN-US" style="letter-spacing:-.05pt">tLoop</span><span lang="EN-US" style="letter-spacing:-1.3pt"> </span><span style="letter-spacing: -.05pt">当做是</span><span style="letter-spacing:-1.3pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">Reactor</span><span lang="EN-US" style="letter-spacing: -1.3pt"> </span><span style="letter-spacing:-.05pt">线程模型中的一个线程</span><span style="letter-spacing:-5.35pt">,</span><span style="letter-spacing:-.05pt">而一个</span><span style="letter-spacing:-1.3pt"> </span><span lang="EN-US" style="letter-spacing: -.05pt">EventLoopGroup</span><span lang="EN-US" style="letter-spacing:-1.3pt"> </span><span style="letter-spacing:-.05pt">类似</span> <span style="letter-spacing:-.1pt">于</span><span style="letter-spacing:-.05pt">一个</span><span style="letter-spacing:-2.05pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">ExecutorService</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="line-height:150%"><span lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin-top:4.5pt;text-indent:1.6pt;line-height:76%"><b><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.65pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">说说</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.25pt"> </span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.55pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">N</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.4pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">e</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">tt</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.35pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">y</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.65pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">的零</span><span style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑;color:#1C1F21; letter-spacing:.6pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">拷贝</span></b><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.9pt;margin-right:1.45pt;margin-bottom: 0cm;margin-left:1.9pt;margin-bottom:.0001pt;text-indent:.2pt;line-height:117%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">&gt; “</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">零拷贝<span lang="EN-US">”</span>是指计算机操作的过程中<span style="letter-spacing:-2.7pt">,</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">CPU </span>不需要为数据在内存之间的拷贝消耗资源<span style="letter-spacing:-2.7pt">。</span>而 它通常是指计算机在网络上发送文件时<span style="letter-spacing:-.5pt">,</span>不需要将文件内容拷贝到用户空间(<span lang="EN-US">User&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Space</span><span style="letter-spacing: -.6pt">)</span>而直接在内核空间(<span lang="EN-US">Kernel<span style="letter-spacing: -.05pt"> </span>Space</span><span style="letter-spacing:-.6pt">)</span>中传输到网络的方式<span style="letter-spacing:-.6pt">。</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:7.45pt;text-indent:2.35pt;line-height: 76%"><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family: 微软雅黑;color:#1C1F21;letter-spacing:.3pt;mso-style-textoutline-type:solid; mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha:100.0%; mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">N</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.25pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">e</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">t</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.1pt;mso-style-textoutline-type:solid;mso-style-textoutline-fill-color: #1C1F21;mso-style-textoutline-fill-alpha:100.0%;mso-style-textoutline-outlinestyle-dpiwidth: .25pt;mso-style-textoutline-outlinestyle-linecap:flat;mso-style-textoutline-outlinestyle-join: miter;mso-style-textoutline-outlinestyle-pctmiterlimit:0%;mso-style-textoutline-outlinestyle-dash: solid;mso-style-textoutline-outlinestyle-align:center;mso-style-textoutline-outlinestyle-compound: simple">t</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.15pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">y</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑; color:#1C1F21;letter-spacing:.15pt"> </span><span style="font-family:&quot;微软雅黑&quot;,sans-serif; mso-bidi-font-family:微软雅黑;color:#1C1F21;letter-spacing:.35pt;mso-style-textoutline-type: solid;mso-style-textoutline-fill-color:#1C1F21;mso-style-textoutline-fill-alpha: 100.0%;mso-style-textoutline-outlinestyle-dpiwidth:.25pt;mso-style-textoutline-outlinestyle-linecap: flat;mso-style-textoutline-outlinestyle-join:miter;mso-style-textoutline-outlinestyle-pctmiterlimit: 0%;mso-style-textoutline-outlinestyle-dash:solid;mso-style-textoutline-outlinestyle-align: center;mso-style-textoutline-outlinestyle-compound:simple">内部执行流程</span><span lang="EN-US" style="font-family:&quot;微软雅黑&quot;,sans-serif;mso-bidi-font-family:微软雅黑"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-top:8.8pt;margin-right:4.6pt;margin-bottom: 0cm;margin-left:1.6pt;margin-bottom:.0001pt;text-indent:.5pt;line-height:117%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.55pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">1.</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.55pt">&nbsp; </span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">Netty</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.55pt"> </span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">的接收和发送</span><span style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.55pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">ByteBuffer</span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.55pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">采用</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.55pt"> </span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">DIRECT</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.55pt"> </span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">BUFFERS</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -5.3pt">,</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">使用</span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21">堆外直接内存进行<span lang="EN-US">&nbsp;&nbsp; Socket </span>读写<span style="letter-spacing:-1.4pt">,</span>不需要进行字节缓冲区的二次拷贝<span style="letter-spacing:-1.4pt">。</span>如果使用传统的堆内存(<span lang="EN-US">HEAP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BUFFERS</span><span style="letter-spacing: -4.4pt">)</span>进行<span style="letter-spacing:-.05pt"> </span><span lang="EN-US">Socket<span style="letter-spacing:-.05pt"> </span></span>读写<span style="letter-spacing: -4.4pt">,</span><span style="letter-spacing:-5.25pt"> </span><span lang="EN-US">JVM </span>会将堆内存<span lang="EN-US"> Buffer </span>拷贝一份到直接内存中<span style="letter-spacing: -4.4pt">,</span>然后才写入<span lang="EN-US"> Socket<span style="letter-spacing:-.05pt"> </span></span>中<span style="letter-spacing:-1.4pt">。</span>相比于堆外直接内存<span style="letter-spacing:-1.4pt">,</span>消息在发送过程中多了一次缓冲区的内存拷贝<span style="letter-spacing:-1.4pt">。</span></span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p> </div><p> <span lang="EN-US" style="font-size:10.5pt;font-family:&quot;Arial&quot;,sans-serif; mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-ansi-language: EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA;mso-no-proof:yes"><br clear="all" style="page-break-before:always;mso-break-type:section-break"> </span> </p><p class="MsoNormal" style="margin-top:3.1pt;margin-right:1.45pt;margin-bottom: 0cm;margin-left:1.6pt;margin-bottom:.0001pt;text-indent:.5pt;line-height:114%"><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">&gt;</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.5pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">2.</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.5pt">&nbsp; </span><span lang="EN-US" style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">Netty</span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.5pt"> </span><span style="font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt">提供了组合</span><span style="font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.5pt"> </span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt">Buffer</span><span lang="EN-US" style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.5pt"> </span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt">对象</span><span style="font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-5.3pt">,</span><span style="font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt">可以聚合多</span><span style="font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21">个<span style="letter-spacing:-.5pt"> </span><span lang="EN-US">ByteBuffer<span style="letter-spacing:-.5pt"> </span></span>对象<span style="letter-spacing:-5.3pt">,</span>用户可以像操作一 <span style="letter-spacing:-.05pt">个</span><span style="letter-spacing:-.95pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">Buffer</span><span lang="EN-US" style="letter-spacing:-.95pt"> </span><span style="letter-spacing: -.05pt">那样方便的对组合</span><span style="letter-spacing:-.95pt"> </span><span lang="EN-US" style="letter-spacing:-.05pt">Buffer</span><span lang="EN-US" style="letter-spacing:-.95pt"> </span><span style="letter-spacing:-.05pt">进行操作</span><span style="letter-spacing:-5.3pt">,</span><span style="letter-spacing:-.05pt">避免了传统通过</span>内存拷贝的方式将几个小<span lang="EN-US"> Buffer<span style="letter-spacing:-.1pt"> </span></span>合并成一个大的<span style="letter-spacing:-.1pt"> </span><span lang="EN-US">Buffer</span><span style="letter-spacing:-5.25pt">。</span></span><span lang="EN-US" style="font-family:宋体;mso-bidi-font-family:宋体"><o:p></o:p></span></p><p> <span lang="EN-US" style="font-size:10.5pt;font-family:宋体;mso-bidi-font-family: 宋体;color:#1C1F21;letter-spacing:-.05pt;mso-ansi-language:EN-US;mso-fareast-language: ZH-CN;mso-bidi-language:AR-SA;mso-no-proof:yes">&gt;</span><span lang="EN-US" style="font-size:10.5pt;font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.4pt;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN; mso-bidi-language:AR-SA;mso-no-proof:yes"> </span><span lang="EN-US" style="font-size:10.5pt;font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.05pt;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN; mso-bidi-language:AR-SA;mso-no-proof:yes">3.</span><span lang="EN-US" style="font-size:10.5pt;font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; letter-spacing:-.4pt;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN; mso-bidi-language:AR-SA;mso-no-proof:yes">&nbsp; </span><span lang="EN-US" style="font-size:10.5pt;font-family:宋体; mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt;mso-ansi-language: EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA;mso-no-proof:yes">Netty</span><span lang="EN-US" style="font-size:10.5pt;font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;letter-spacing:-.4pt;mso-ansi-language:EN-US;mso-fareast-language: ZH-CN;mso-bidi-language:AR-SA;mso-no-proof:yes"> </span><span style="font-size: 10.5pt;font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing: -.05pt;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN;mso-bidi-language: AR-SA;mso-no-proof:yes">的文件传输采用了</span><span style="font-size:10.5pt; font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.4pt; mso-ansi-language:EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA; mso-no-proof:yes"> </span><span lang="EN-US" style="font-size:10.5pt;font-family: 宋体;mso-bidi-font-family:宋体;color:#1C1F21;letter-spacing:-.05pt;mso-ansi-language: EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA;mso-no-proof:yes">t</span><span lang="EN-US" style="font-size:10.5pt;font-family:宋体;mso-bidi-font-family:宋体; color:#1C1F21;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN;mso-bidi-language: AR-SA;mso-no-proof:yes">ransferTo<span style="letter-spacing:-.4pt"> </span></span><span style="font-size:10.5pt;font-family:宋体;mso-bidi-font-family:宋体;color:#1C1F21; mso-ansi-language:EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA; mso-no-proof:yes">方法<span style="letter-spacing:-5.3pt">,</span>它可以直接将文件缓冲区的数据发送到</span><br></p>

上一篇 下一篇

热门资讯