{"id":11510,"date":"2023-11-28T22:21:06","date_gmt":"2023-11-28T14:21:06","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=11510"},"modified":"2023-12-11T11:01:53","modified_gmt":"2023-12-11T03:01:53","slug":"spring-zhongioc-de-que-dian-shi-shen-me","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/spring-zhongioc-de-que-dian-shi-shen-me\/","title":{"rendered":"Spring\u4e2dIOC\u7684\u7f3a\u70b9\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p>\u5c3d\u7ba1Spring\u7684IoC\u5bb9\u5668\u5e26\u6765\u4e86\u8bb8\u591a\u4f18\u70b9\uff0c\u4f46\u4e5f\u5b58\u5728\u4e00\u4e9b\u6f5c\u5728\u7684\u7f3a\u70b9\u548c\u8003\u8651\u4e8b\u9879\uff1a<\/p>\n<ol>\n<li>\n<strong>\u590d\u6742\u6027\uff08Complexity\uff09\uff1a<\/strong><\/p>\n<ul>\n<li>\u5bf9\u4e8e\u5c0f\u578b\u9879\u76ee\uff0c\u4f7f\u7528IoC\u5bb9\u5668\u53ef\u80fd\u663e\u5f97\u8fc7\u4e8e\u590d\u6742\u3002\u5728\u7b80\u5355\u7684\u573a\u666f\u4e2d\uff0c\u624b\u52a8\u8fdb\u884c\u5bf9\u8c61\u7684\u521b\u5efa\u548c\u7ba1\u7406\u53ef\u80fd\u66f4\u52a0\u76f4\u89c2\u548c\u5bb9\u6613\u7406\u89e3\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u8fd0\u884c\u65f6\u6027\u80fd\u5f00\u9500\uff08Runtime Performance Overhead\uff09\uff1a<\/strong><\/p>\n<ul>\n<li>IoC\u5bb9\u5668\u5728\u8fd0\u884c\u65f6\u8d1f\u8d23\u5bf9\u8c61\u7684\u521b\u5efa\u548c\u4f9d\u8d56\u6ce8\u5165\uff0c\u8fd9\u53ef\u80fd\u5f15\u5165\u4e00\u4e9b\u6027\u80fd\u5f00\u9500\u3002\u5c24\u5176\u662f\u5bf9\u4e8e\u5927\u578b\u548c\u9ad8\u5e76\u53d1\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u8fd9\u4e9b\u5f00\u9500\u53ef\u80fd\u6210\u4e3a\u6027\u80fd\u74f6\u9888\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u5b66\u4e60\u66f2\u7ebf\uff08Learning Curve\uff09\uff1a<\/strong><\/p>\n<ul>\n<li>\u5b66\u4e60\u5e76\u7406\u89e3IoC\u5bb9\u5668\u7684\u6982\u5ff5\u548c\u4f7f\u7528\u65b9\u5f0f\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u65f6\u95f4\u3002\u5bf9\u4e8e\u65b0\u624b\u6765\u8bf4\uff0c\u53ef\u80fd\u9700\u8981\u4e00\u5b9a\u7684\u5b66\u4e60\u66f2\u7ebf\uff0c\u5c24\u5176\u662f\u7406\u89e3\u5982\u4f55\u914d\u7f6e\u548c\u4f7f\u7528IoC\u5bb9\u5668\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u8fc7\u5ea6\u4f7f\u7528\uff08Overuse\uff09\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u4e00\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f00\u53d1\u8005\u53ef\u80fd\u4f1a\u8fc7\u5ea6\u4f7f\u7528IoC\u5bb9\u5668\uff0c\u5bfc\u81f4\u914d\u7f6e\u6587\u4ef6\u53d8\u5f97\u590d\u6742\uff0c\u589e\u52a0\u4e86\u7ef4\u62a4\u6210\u672c\u3002\u5728\u67d0\u4e9b\u7b80\u5355\u7684\u60c5\u51b5\u4e0b\uff0c\u624b\u52a8\u7ba1\u7406\u5bf9\u8c61\u53ef\u80fd\u66f4\u52a0\u76f4\u89c2\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u914d\u7f6e\u590d\u6742\u6027\uff08Configuration Complexity\uff09\uff1a<\/strong><\/p>\n<ul>\n<li>\u968f\u7740\u9879\u76ee\u7684\u589e\u957f\uff0cIoC\u5bb9\u5668\u7684\u914d\u7f6e\u6587\u4ef6\u53ef\u80fd\u53d8\u5f97\u5e9e\u5927\u548c\u590d\u6742\u3002\u6b63\u786e\u914d\u7f6e\u5bf9\u8c61\u7684\u4f9d\u8d56\u5173\u7cfb\u548c\u4f5c\u7528\u57df\u53ef\u80fd\u9700\u8981\u66f4\u591a\u7684\u52aa\u529b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u8fd0\u884c\u65f6\u9519\u8bef\u96be\u4ee5\u8c03\u8bd5\uff08Runtime Errors are Hard to Debug\uff09\uff1a<\/strong><\/p>\n<ul>\n<li>\u7531\u4e8e\u5bf9\u8c61\u7684\u521b\u5efa\u548c\u4f9d\u8d56\u6ce8\u5165\u662f\u5728\u8fd0\u884c\u65f6\u8fdb\u884c\u7684\uff0c\u56e0\u6b64\u4e00\u4e9b\u914d\u7f6e\u9519\u8bef\u6216\u4f9d\u8d56\u5173\u7cfb\u9519\u8bef\u53ef\u80fd\u5728\u8fd0\u884c\u65f6\u624d\u80fd\u88ab\u53d1\u73b0\uff0c\u4f7f\u5f97\u8c03\u8bd5\u53d8\u5f97\u66f4\u52a0\u56f0\u96be\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u8fc7\u5ea6\u89e3\u8026\uff08Over-Decoupling\uff09\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u8fc7\u5ea6\u4f7f\u7528IoC\u5bb9\u5668\u53ef\u80fd\u5bfc\u81f4\u8fc7\u5ea6\u89e3\u8026\uff0c\u4f7f\u5f97\u4ee3\u7801\u53d8\u5f97\u96be\u4ee5\u7406\u89e3\u3002\u5728\u67d0\u4e9b\u573a\u666f\u4e2d\uff0c\u663e\u5f0f\u7684\u4f9d\u8d56\u5173\u7cfb\u53ef\u80fd\u66f4\u6709\u52a9\u4e8e\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u5bb9\u5668\u7684\u521d\u59cb\u5316\u65f6\u95f4\uff08Container Initialization Time\uff09\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u65f6\uff0cIoC\u5bb9\u5668\u9700\u8981\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u5305\u62ec\u8bfb\u53d6\u914d\u7f6e\u3001\u521b\u5efa\u5bf9\u8c61\u7b49\u3002\u5bf9\u4e8e\u5927\u578b\u5e94\u7528\u7a0b\u5e8f\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u8f83\u957f\u7684\u542f\u52a8\u65f6\u95f4\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u867d\u7136\u5b58\u5728\u8fd9\u4e9b\u6f5c\u5728\u7684\u7f3a\u70b9\uff0c\u4f46Spring\u6846\u67b6\u5df2\u7ecf\u901a\u8fc7\u4e0d\u65ad\u7684\u6f14\u8fdb\u548c\u6539\u8fdb\uff0c\u4ee5\u51cf\u8f7b\u8fd9\u4e9b\u95ee\u9898\u3002\u5728\u4f7f\u7528IoC\u5bb9\u5668\u65f6\uff0c\u5f00\u53d1\u8005\u9700\u8981\u6839\u636e\u9879\u76ee\u7684\u89c4\u6a21\u3001\u590d\u6742\u6027\u548c\u9700\u6c42\u6765\u6743\u8861\u4f7f\u7528IoC\u7684\u5229\u5f0a\uff0c\u786e\u4fdd\u9009\u62e9\u9002\u5408\u9879\u76ee\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c3d\u7ba1Spring\u7684IoC\u5bb9\u5668\u5e26\u6765\u4e86\u8bb8\u591a\u4f18\u70b9\uff0c\u4f46\u4e5f\u5b58\u5728\u4e00\u4e9b\u6f5c\u5728\u7684\u7f3a\u70b9\u548c\u8003\u8651\u4e8b\u9879\uff1a \u590d\u6742\u6027\uff08Complexity\uff09 [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121],"tags":[],"class_list":["post-11510","post","type-post","status-publish","format-standard","hentry","category-spring"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/11510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=11510"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/11510\/revisions"}],"predecessor-version":[{"id":17060,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/11510\/revisions\/17060"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=11510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=11510"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=11510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}