{"id":52196,"date":"2025-08-11T11:24:09","date_gmt":"2025-08-11T03:24:09","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/52196.html"},"modified":"2025-08-11T11:24:09","modified_gmt":"2025-08-11T03:24:09","slug":"spring%e9%9d%a2%e8%af%95%e5%8f%8d%e6%9d%80%e6%8c%87%e5%8d%97%ef%bc%9a%e6%8a%8aioc%e5%bd%93%e5%a9%9a%e4%bb%8b%e6%89%80%ef%bc%8caop%e5%bd%93%e5%af%bc%e6%bc%94%ef%bc%8c%e4%ba%8b%e5%8a%a1%e5%bd%93aa","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/52196.html","title":{"rendered":"Spring\u9762\u8bd5\u53cd\u6740\u6307\u5357\uff1a\u628aIOC\u5f53\u5a5a\u4ecb\u6240\uff0cAOP\u5f53\u5bfc\u6f14\uff0c\u4e8b\u52a1\u5f53AA\u5236"},"content":{"rendered":"<h3 style=\"background-color:transparent\">&#x1f525; \u5f00\u573a\u66b4\u51fb&#xff1a;Spring\u9762\u8bd5\u4e09\u8fde\u95ee\u6df1\u5ea6\u89e3\u6790<\/h3>\n<p>&#034;\u8bf4\u8bf4\u4f60\u5bf9IOC\u7684\u7406\u89e3&#xff1f;&#034; &#034;AOP\u6709\u54ea\u4e9b\u5b9e\u73b0\u65b9\u5f0f&#xff1f;&#034; &#034;Spring\u4e8b\u52a1\u4f20\u64ad\u673a\u5236\u662f\u4ec0\u4e48&#xff1f;&#034;<\/p>\n<p>\u8fd9\u4e9b\u9ad8\u9891\u95ee\u9898\u80cc\u540e\u9690\u85cf\u7740\u9762\u8bd5\u5b98\u7684\u4e09\u5927\u8003\u5bdf\u7ef4\u5ea6&#xff1a;<\/p>\n<li>\n<p>\u6846\u67b6\u8bbe\u8ba1\u601d\u60f3&#xff1a;\u662f\u5426\u7406\u89e3\u89e3\u8026\u3001\u52a8\u6001\u4ee3\u7406\u7b49\u5e95\u5c42\u54f2\u5b66<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u6218\u5e94\u7528\u80fd\u529b&#xff1a;\u80fd\u5426\u5728\u9879\u76ee\u4e2d\u6b63\u786e\u8fd0\u7528\u6838\u5fc3\u7279\u6027<\/p>\n<\/li>\n<li>\n<p>\u6392\u9519\u7ecf\u9a8c\u79ef\u7d2f&#xff1a;\u662f\u5426\u8e29\u8fc7\u5178\u578b\u5751\u70b9\u5e76\u5f62\u6210\u89e3\u51b3\u65b9\u6848<\/p>\n<\/li>\n<h3 style=\"text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"302\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811032407-689962570590d.png\" width=\"304\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"301\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811032407-6899625748656.png\" width=\"225\" \/><\/h3>\n<p style=\"text-align:center\">&#034;\u5f53for\u5faa\u73af\u5361\u6b7b\u5728i&#043;&#043;\u65f6&#xff0c;\u8bb0\u5f97\u4f60\u8fd8\u6709\u9012\u5f52\u8fd9\u4e2a\u9009\u62e9\u3002\u751f\u6d3b\u4e5f\u662f&#xff0c;\u76f4\u7ebf\u8d70\u4e0d\u901a\u5c31\u6362\u4e2a\u7ef4\u5ea6\u601d\u8003&#034; \u3002<\/p>\n<hr \/>\n<h3 style=\"background-color:transparent\">&#x1f4e6; \u7b2c\u4e00\u7ae0&#xff1a;IOC\u5bb9\u5668\u2014\u2014\u5bf9\u8c61\u6cbb\u7406\u4f53\u7cfb(Spring\u7684&#034;\u5bf9\u8c61\u5a5a\u4ecb\u6240&#034;)<\/h3>\n<h4>&#x1f4a1; \u9762\u8bd5\u5b98\u5230\u5e95\u5728\u95ee\u4ec0\u4e48&#xff1f;<\/h4>\n<p>\u5f53\u9762\u8bd5\u5b98\u95ee&#034;IOC\u539f\u7406&#034;\u65f6&#xff0c;\u5176\u5b9e\u662f\u60f3\u8003\u5bdf&#xff1a;<\/p>\n<li>\n<p>\u4f60\u662f\u5426\u7406\u89e3&#034;\u63a7\u5236\u53cd\u8f6c&#034;\u7684\u8bbe\u8ba1\u54f2\u5b66<\/p>\n<\/li>\n<li>\n<p>\u80fd\u5426\u8bf4\u6e05\u695a\u5bb9\u5668\u5982\u4f55\u7ba1\u7406Bean\u751f\u547d\u5468\u671f<\/p>\n<\/li>\n<li>\n<p>\u662f\u5426\u4e86\u89e3\u4f9d\u8d56\u6ce8\u5165\u7684\u591a\u79cd\u5b9e\u73b0\u65b9\u5f0f<\/p>\n<\/li>\n<h4>&#x1f3ad; \u8da3\u5473\u7c7b\u6bd4\u7248\u89e3\u91ca<\/h4>\n<p>\u60f3\u8c61IOC\u5bb9\u5668\u662f\u4e2a\u667a\u80fd\u5a5a\u4ecb\u6240&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4f20\u7edf\u5f00\u53d1&#xff1a;\u7a0b\u5e8f\u5458\u50cf\u7126\u8651\u7684\u7236\u6bcd&#xff08;new Object()\u5230\u5904\u7ed9\u5b69\u5b50\u627e\u5bf9\u8c61&#xff09;<\/p>\n<\/li>\n<li>\n<p>IOC\u6a21\u5f0f&#xff1a;\u628a\u5b50\u5973\u7684\u5a5a\u604b\u6743\u4ea4\u7ed9\u5a5a\u4ecb\u6240&#xff08;\u5bb9\u5668&#xff09;&#xff0c;\u7236\u6bcd\u53ea\u9700\u58f0\u660e\u9700\u6c42&#xff08;&#064;Autowired&#xff09;<\/p>\n<\/li>\n<\/ul>\n<p>\/\/ \u4f20\u7edf\u786c\u7f16\u7801\u5f0f\u76f8\u4eb2<br \/>\nPerson xiaoming &#061; new Person();<br \/>\nxiaoming.setPartner(new Person(&#034;\u5c0f\u7ea2&#034;));<br \/>\n\/\/ IOC\u5f0f\u81ea\u7531\u604b\u7231<br \/>\n&#064;Component<br \/>\npublic class Xiaoming {<br \/>\n    &#064;Autowired<br \/>\n    \/\/ \u5a5a\u4ecb\u6240\u81ea\u52a8\u5339\u914d<br \/>\n    private Partner partner;<br \/>\n} <\/p>\n<h4>\u9ad8\u9891\u8ffd\u95ee\u62c6\u62db<\/h4>\n<li>\n<p>Bean\u4f5c\u7528\u57df\u6709\u54ea\u4e9b&#xff1f;<\/p>\n<ul>\n<li>\n<p>\u5355\u8eab\u72d7&#xff08;prototype&#xff09;&#xff1a;\u6bcf\u6b21getBean\u90fd\u65b0\u5efa<\/p>\n<\/li>\n<li>\n<p>\u6a21\u8303\u592b\u59bb&#xff08;singleton&#xff09;&#xff1a;\u5168\u5c40\u552f\u4e00\u5b9e\u4f8b<\/p>\n<\/li>\n<li>\n<p>\u7f51\u604b\u5bf9\u8c61&#xff08;request\/session&#xff09;&#xff1a;\u7279\u5b9a\u573a\u666f\u6709\u6548<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5faa\u73af\u4f9d\u8d56\u600e\u4e48\u89e3\u51b3&#xff1f; \u597d\u6bd4A\u548cB\u4e92\u76f8\u6697\u604b&#xff0c;Spring\u7684\u89e3\u51b3\u65b9\u6848&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4e09\u7ea7\u7f13\u5b58\u5c31\u50cf&#034;\u4f20\u8bdd\u673a\u5236&#034;<\/p>\n<\/li>\n<li>\n<p>\u5148\u7ed9\u534a\u6210\u54c1\u5bf9\u8c61&#xff08;\u65e9\u671f\u5f15\u7528&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u7b49\u53cc\u65b9\u90fd\u51c6\u5907\u597d\u518d\u6b63\u5f0f&#034;\u7ed3\u5a5a&#034;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<h4>&#x1f4a1; \u9ad8\u9636\u8003\u5bdf\u8981\u70b9<\/h4>\n<p>1.\u8bbe\u8ba1\u6a21\u5f0f\u5bf9\u6bd4&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4f20\u7edf\u5de5\u5382\u6a21\u5f0f\u4e0eIOC\u5bb9\u5668\u7684\u81ea\u52a8\u5316\u7ba1\u7406\u5dee\u5f02<\/p>\n<\/li>\n<\/ul>\n<li>\n<p>\u200c\u4f9d\u8d56\u7ba1\u7406\u65b9\u5f0f\u4e0d\u540c\u200c<\/p>\n<ul>\n<li>\u200c\u5de5\u5382\u6a21\u5f0f\u200c&#xff1a;\u9700\u624b\u52a8\u521b\u5efa\u5bf9\u8c61\u5e76\u7ba1\u7406\u4f9d\u8d56&#xff08;\u5982new UserDaoImpl()&#xff09;&#xff0c;\u8c03\u7528\u8005\u9700\u4e3b\u52a8\u83b7\u53d6\u4f9d\u8d56\u5bf9\u8c61&#xff0c;\u5bfc\u81f4\u4ee3\u7801\u8026\u5408\u5ea6\u9ad8\u3002\u82e5\u9700\u66f4\u6362\u5b9e\u73b0\u7c7b&#xff08;\u5982\u6539\u7528UserDaoMysqlImpl&#xff09;&#xff0c;\u5fc5\u987b\u4fee\u6539\u6e90\u7801\u3002<\/li>\n<li>\u200cIOC\u5bb9\u5668\u200c&#xff1a;\u901a\u8fc7\u4f9d\u8d56\u6ce8\u5165&#xff08;DI&#xff09;\u81ea\u52a8\u7ba1\u7406\u4f9d\u8d56\u5173\u7cfb\u3002\u5bf9\u8c61\u4ec5\u9700\u58f0\u660e\u63a5\u53e3&#xff08;\u5982&#064;Autowired UserDao&#xff09;&#xff0c;\u5bb9\u5668\u52a8\u6001\u6ce8\u5165\u5177\u4f53\u5b9e\u73b0&#xff0c;\u65e0\u9700\u4fee\u6539\u4e1a\u52a1\u4ee3\u7801\u5373\u53ef\u5207\u6362\u5b9e\u73b0\u7c7b&#xff08;\u5982\u914d\u7f6e\u5207\u6362MySQL\u5230Oracle\u9a71\u52a8&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200c\u529f\u80fd\u6269\u5c55\u6027\u4e0e\u751f\u547d\u5468\u671f\u7ba1\u7406\u200c<\/p>\n<ul>\n<li>\u5de5\u5382\u6a21\u5f0f\u4ec5\u805a\u7126\u5bf9\u8c61\u521b\u5efa&#xff0c;\u8d44\u6e90\u521d\u59cb\u5316\/\u9500\u6bc1\u9700\u624b\u52a8\u5904\u7406&#xff0c;\u96be\u4ee5\u5b9e\u73b0\u5355\u4f8b\u590d\u7528\u6216\u4f5c\u7528\u57df\u63a7\u5236\u3002<\/li>\n<li>IOC\u5bb9\u5668\u7edf\u4e00\u7ba1\u7406\u5bf9\u8c61\u751f\u547d\u5468\u671f&#xff08;\u5982\u5355\u4f8b\/\u539f\u578b\u4f5c\u7528\u57df&#xff09;&#xff0c;\u652f\u6301&#064;PostConstruct\u521d\u59cb\u5316\u903b\u8f91\u548cAOP\u589e\u5f3a&#xff08;\u5982\u4e8b\u52a1\u4ee3\u7406&#xff09;&#xff0c;\u63d0\u5347\u8d44\u6e90\u5229\u7528\u7387\u4e0e\u6269\u5c55\u6027\u3002<\/li>\n<\/ul>\n<\/li>\n<ul>\n<li>\n<p>\u5355\u4f8b\u4f5c\u7528\u57df\u4e0b\u7684\u7ebf\u7a0b\u5b89\u5168\u4fdd\u8bc1\u673a\u5236<\/p>\n<\/li>\n<\/ul>\n<li>\n<p>\u200c\u997f\u6c49\u5f0f&#xff08;\u9884\u52a0\u8f7d&#xff09;\u200c \u7c7b\u52a0\u8f7d\u65f6\u76f4\u63a5\u521d\u59cb\u5316\u9759\u6001\u5b9e\u4f8b&#xff08;<span style=\"background-color:#a5a5a5\">private static final Singleton instance &#061; new Singleton()<\/span>&#xff09;&#xff0c;\u5229\u7528JVM\u7c7b\u52a0\u8f7d\u673a\u5236\u4fdd\u8bc1\u7ebf\u7a0b\u5b89\u5168&#xff0c;\u4f46\u53ef\u80fd\u9020\u6210\u8d44\u6e90\u6d6a\u8d39\u3002<\/p>\n<\/li>\n<li>\n<p>\u200c\u53cc\u91cd\u68c0\u67e5\u9501&#xff08;DCL&#xff09;\u200c \u7ed3\u5408volatile\u7981\u6b62\u6307\u4ee4\u91cd\u6392\u4e0esynchronized\u540c\u6b65\u5757&#xff0c;\u5b9e\u73b0\u5ef6\u8fdf\u52a0\u8f7d\u4e14\u907f\u514d\u9501\u7ade\u4e89&#xff1a;<\/p>\n<p> public class Singleton {<br \/>\n    private static volatile Singleton instance;<br \/>\n    public static Singleton getInstance() {<br \/>\n        if (instance &#061;&#061; null) {                    \/\/ \u7b2c\u4e00\u6b21\u68c0\u67e5&#xff08;\u65e0\u9501&#xff09;<br \/>\n            synchronized (Singleton.class) {       \/\/ \u52a0\u9501<br \/>\n                if (instance &#061;&#061; null) {            \/\/ \u7b2c\u4e8c\u6b21\u68c0\u67e5&#xff08;\u907f\u514d\u91cd\u590d\u521b\u5efa&#xff09;<br \/>\n                    instance &#061; new Singleton();<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n        return instance;<br \/>\n    }<br \/>\n}<\/p>\n<p>volatile\u786e\u4fdd\u591a\u7ebf\u7a0b\u53ef\u89c1\u6027&#xff0c;\u9632\u6b62\u672a\u5b8c\u5168\u521d\u59cb\u5316\u7684\u5bf9\u8c61\u9038\u51fa\u3002<\/p>\n<\/li>\n<li>\n<p>\u200c\u9759\u6001\u5185\u90e8\u7c7b\u200c \u5229\u7528\u9759\u6001\u5185\u90e8\u7c7b\u9996\u6b21\u8c03\u7528\u65f6\u52a0\u8f7d\u7684\u7279\u6027&#xff08;Holder\u7c7b&#xff09;&#xff0c;\u5b9e\u73b0\u61d2\u52a0\u8f7d\u4e0e\u7ebf\u7a0b\u5b89\u5168&#xff1a;<\/p>\n<p> public class Singleton {<br \/>\n    private static class Holder {<br \/>\n        static final Singleton INSTANCE &#061; new Singleton();<br \/>\n    }<br \/>\n    public static Singleton getInstance() {<br \/>\n        return Holder.INSTANCE;<br \/>\n    }<br \/>\n}<\/p>\n<p>\u65e0\u9700\u540c\u6b65\u9501&#xff0c;\u6027\u80fd\u4e0e\u5b89\u5168\u6027\u517c\u987e\u3002<\/p>\n<\/li>\n<p>\u5173\u952e\u5dee\u5f02\u603b\u7ed3:<\/p>\n<table>\n<tr>\u200c\u7ef4\u5ea6\u200c\u200c\u5de5\u5382\u6a21\u5f0f\u200c\u200cIOC\u5bb9\u5668\u200c<\/tr>\n<tbody>\n<tr>\n<td style=\"text-align:center\">\u4f9d\u8d56\u63a7\u5236<\/td>\n<td style=\"text-align:center\">\u8c03\u7528\u8005\u4e3b\u52a8\u83b7\u53d6<\/td>\n<td style=\"text-align:center\">\u5bb9\u5668\u88ab\u52a8\u6ce8\u5165&#xff08;\u63a7\u5236\u53cd\u8f6c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">\u53ef\u7ef4\u62a4\u6027<\/td>\n<td style=\"text-align:center\">\u4fee\u6539\u4f9d\u8d56\u9700\u91cd\u6784\u4ee3\u7801<\/td>\n<td style=\"text-align:center\">\u4ec5\u8c03\u6574\u914d\u7f6e&#xff0c;\u4e1a\u52a1\u4ee3\u7801\u65e0\u4fb5\u5165<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">\u7ebf\u7a0b\u5b89\u5168\u4fdd\u969c<\/td>\n<td style=\"text-align:center\">\u9700\u81ea\u884c\u5b9e\u73b0&#xff08;\u5982\u53cc\u91cd\u68c0\u67e5\u9501&#xff09;<\/td>\n<td style=\"text-align:center\">\u5bb9\u5668\u81ea\u52a8\u7ba1\u7406\u5355\u4f8b\u751f\u547d\u5468\u671f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>2.\u6e90\u7801\u7ea7\u8fa8\u6790&#xff1a;<\/p>\n<p>\/\/ \u7ec4\u4ef6\u6ce8\u89e3\u7684\u5c42\u7ea7\u5316\u8bbe\u8ba1<br \/>\n &#064;Controller \/\/ MVC\u8bf7\u6c42\u5904\u7406\u5165\u53e3<br \/>\n &#064;Service \/\/ \u4e1a\u52a1\u903b\u8f91\u805a\u5408\u5c42<br \/>\n &#064;Repository \/\/ \u6301\u4e45\u5c42\u5f02\u5e38\u8f6c\u8bd1\u5668<br \/>\n &#064;Component \/\/ \u901a\u7528\u7ec4\u4ef6\u57fa\u6ce8\u89e3 <\/p>\n<p>\u6838\u5fc3\u673a\u5236&#xff1a;\u63a7\u5236\u53cd\u8f6c\u4e0e\u4f9d\u8d56\u6ce8\u5165<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0IOC&#xff08;\u63a7\u5236\u53cd\u8f6c&#xff09;\u901a\u8fc7\u8f6c\u79fb\u5bf9\u8c61\u521b\u5efa\u4e0e\u4f9d\u8d56\u7ba1\u7406\u7684\u63a7\u5236\u6743\u5b9e\u73b0\u89e3\u8026\u3002\u4f20\u7edf\u7f16\u7801\u9700\u4e3b\u52a8new\u5bf9\u8c61&#xff08;\u6b63\u8f6c&#xff09;&#xff0c;\u800cIOC\u5bb9\u5668\u88ab\u52a8\u63a5\u7ba1\u5bf9\u8c61\u751f\u547d\u5468\u671f&#xff0c;\u6309\u9700\u6ce8\u5165\u4f9d\u8d56&#xff08;\u53cd\u8f6c&#xff09;\u3002<\/p>\n<p>\u6e90\u7801\u5b9e\u73b0\u7684\u5173\u952e\u6d41\u7a0b&#xff1a;<\/p>\n<li>\u200cBean\u5b9a\u4e49\u52a0\u8f7d\u200c\n<ul>\n<li>\u89e3\u6790XML\u914d\u7f6e\u3001\u6ce8\u89e3\u6216Java Config&#xff0c;\u5c06&lt;bean&gt;\u6216&#064;Bean\u8f6c\u5316\u4e3aBeanDefinition\u5bf9\u8c61&#xff08;\u5b58\u50a8\u7c7b\u8def\u5f84\u3001\u4f5c\u7528\u57df\u7b49\u5143\u6570\u636e&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u200c\u5b9e\u4f8b\u5316\u4e0e\u4f9d\u8d56\u6ce8\u5165\u200c\n<ul>\n<li>\u5bb9\u5668\u901a\u8fc7\u53cd\u5c04\u8c03\u7528\u6784\u9020\u51fd\u6570\u5b9e\u4f8b\u5316Bean&#xff0c;\u518d\u9012\u5f52\u6ce8\u5165\u4f9d\u8d56&#xff08;\u5c5e\u6027\u8d4b\u503c\u6216\u6784\u9020\u5668\u53c2\u6570&#xff09;\u3002<\/li>\n<li>\u4f9d\u8d56\u89e3\u6790\u6d41\u7a0b&#xff1a;\u68c0\u67e5\u5b57\u6bb5&#064;Autowired\u2192\u67e5\u627e\u5339\u914d\u7c7b\u578bBean\u2192\u9012\u5f52\u6ce8\u5165\u4f9d\u8d56\u94fe\u3002<\/li>\n<\/ul>\n<p>  \/\/ \u7b80\u5316\u7684\u4f9d\u8d56\u6ce8\u5165\u4f2a\u4ee3\u7801<br \/>\nvoid populateBean(Bean bean) {<br \/>\n   for (Field field : bean.getFields()) {<br \/>\n      if (field.isAnnotationPresent(Autowired.class)) {<br \/>\n          Object dependency &#061; getBean(field.getType()); \/\/ \u4ece\u5bb9\u5668\u83b7\u53d6\u4f9d\u8d56<br \/>\n          field.set(bean, dependency); \/\/ \u53cd\u5c04\u6ce8\u5165<br \/>\n      }<br \/>\n   }<br \/>\n}  <\/p>\n<\/li>\n<li>\u200c\u751f\u547d\u5468\u671f\u56de\u8c03\u200c\n<ul>\n<li>\n<p>\u8c03\u7528&#064;PostConstruct\u521d\u59cb\u5316\u65b9\u6cd5&#xff0c;\u652f\u6301InitializingBean\u63a5\u53e3\u6216\u81ea\u5b9a\u4e49init-method\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<p>\u4e0e\u4f20\u7edf\u5de5\u5382\u6a21\u5f0f\u7684\u6e90\u7801\u7ea7\u5dee\u5f02<\/p>\n<table>\n<tr>\u200c\u7ef4\u5ea6\u200c\u200c\u5de5\u5382\u6a21\u5f0f\u200c\u200cIOC\u5bb9\u5668\u200c<\/tr>\n<tbody>\n<tr>\n<td style=\"text-align:center\">\u200c\u5bf9\u8c61\u521b\u5efa\u200c<\/td>\n<td style=\"text-align:center\">\u786c\u7f16\u7801new\u6216\u9759\u6001\u5de5\u5382\u65b9\u6cd5&#xff0c;\u8026\u5408\u5177\u4f53\u5b9e\u73b0\u7c7b<\/td>\n<td style=\"text-align:center\">\u5bb9\u5668\u52a8\u6001\u53cd\u5c04\u5b9e\u4f8b\u5316&#xff0c;\u4f9d\u8d56\u63a5\u53e3\u800c\u975e\u5b9e\u73b0\u7c7b<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">\u200c\u4f9d\u8d56\u7ba1\u7406\u200c<\/td>\n<td style=\"text-align:center\">\u8c03\u7528\u65b9\u4e3b\u52a8\u83b7\u53d6\u4f9d\u8d56&#xff08;Factory.getXxx()&#xff09;<\/td>\n<td style=\"text-align:center\">\u5bb9\u5668\u81ea\u52a8\u6ce8\u5165\u4f9d\u8d56&#xff08;\u5b57\u6bb5\/\u6784\u9020\u5668\u6ce8\u5165&#xff09;<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">\u200c\u914d\u7f6e\u6269\u5c55\u200c<\/td>\n<td style=\"text-align:center\">\u4fee\u6539\u4f9d\u8d56\u9700\u91cd\u6784\u6e90\u7801<\/td>\n<td style=\"text-align:center\">\u4ec5\u8c03\u6574BeanDefinition&#xff08;\u5982XML\u2192\u6ce8\u89e3&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"background-color:transparent\">\u4f9d\u8d56\u6ce8\u5165\u7684\u6e90\u7801\u5b9e\u73b0\u65b9\u5f0f<\/p>\n<p>IOC\u5bb9\u5668\u652f\u6301\u4e09\u79cd\u4f9d\u8d56\u6ce8\u5165\u6a21\u5f0f&#xff08;\u6e90\u7801\u7ea7\u5b9e\u73b0\u5dee\u5f02&#xff09;&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 1.Setter\u6ce8\u5165\u200c<\/p>\n<p>\u901a\u8fc7BeanDefinition\u89e3\u6790&lt;property&gt;\u6807\u7b7e\u6216&#064;Value&#xff0c;\u8c03\u7528Setter\u65b9\u6cd5\u8d4b\u503c\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 2.\u6784\u9020\u5668\u6ce8\u5165\u200c<\/p>\n<p>\u89e3\u6790\u6784\u9020\u53c2\u6570\u7c7b\u578b&#xff0c;\u6309\u7c7b\u578b\/\u540d\u79f0\u5339\u914d\u5bb9\u5668\u4e2dBean&#xff0c;\u4f18\u5148\u7528\u4e8e\u5f3a\u4f9d\u8d56\u573a\u666f\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 3.\u5b57\u6bb5\u6ce8\u5165\u200c<\/p>\n<p>\u76f4\u63a5\u53cd\u5c04\u4fee\u6539\u5b57\u6bb5\u503c&#xff08;\u9700&#064;Autowired&#xff09;&#xff0c;\u4f46\u7834\u574f\u5c01\u88c5\u6027\u3002<\/p>\n<\/p>\n<p style=\"background-color:transparent\">Bean\u6ce8\u518c\u7684\u9ad8\u7ea7\u673a\u5236<\/p>\n<p>Spring\u901a\u8fc7\u6269\u5c55\u70b9\u589e\u5f3aIOC\u7075\u6d3b\u6027&#xff1a;<\/p>\n<ul>\n<li>\u200cFactoryBean\u200c&#xff1a;\u52a8\u6001\u751f\u6210\u4ee3\u7406\u5bf9\u8c61&#xff08;\u5982Feign\u63a5\u53e3&#xff09;&#xff0c;\u5bb9\u5668\u5b9e\u9645\u5b58\u50a8FactoryBean.getObject()\u7684\u8fd4\u56de\u503c\u3002<\/li>\n<li>\u200cImportBeanDefinitionRegistrar\u200c&#xff1a;\u52a8\u6001\u6ce8\u518cBeanDefinition&#xff08;SpringBoot\u542f\u52a8\u7c7b\u6838\u5fc3&#xff09;\u3002<\/li>\n<li>\u200cImportSelector\u200c&#xff1a;\u6279\u91cf\u5bfc\u5165\u914d\u7f6e\u7c7b&#xff0c;\u5b9e\u73b0\u6761\u4ef6\u88c5\u914d\u3002<\/li>\n<\/ul>\n<p style=\"background-color:transparent\">\n<p style=\"background-color:transparent\">\u7ebf\u7a0b\u5b89\u5168\u7684\u5355\u4f8b\u7ba1\u7406<\/p>\n<p>\u5bb9\u5668\u9ed8\u8ba4\u5355\u4f8bBean\u901a\u8fc7\u200c\u53cc\u91cd\u68c0\u67e5\u9501\u4e0evolatile\u200c \u4fdd\u8bc1\u7ebf\u7a0b\u5b89\u5168&#xff1a;<\/p>\n<p> \/\/ \u7b80\u5316\u7684\u5355\u4f8bBean\u521b\u5efa\u4f2a\u4ee3\u7801<br \/>\npublic Object getSingleton(String beanName) {<br \/>\n    Object bean &#061; singletonCache.get(beanName);<br \/>\n    if (bean &#061;&#061; null) {<br \/>\n        synchronized (this) {<br \/>\n            bean &#061; singletonCache.get(beanName);<br \/>\n            if (bean &#061;&#061; null) {<br \/>\n                bean &#061; createBean(beanName); \/\/ \u53cd\u5c04\u521b\u5efa<br \/>\n                singletonCache.put(beanName, bean);<br \/>\n            }<br \/>\n        }<br \/>\n    }<br \/>\n    return bean;<br \/>\n}  <\/p>\n<p>\u4f9d\u8d56ConcurrentHashMap\u7f13\u5b58\u5355\u4f8b&#xff0c;\u907f\u514d\u91cd\u590d\u521b\u5efa\u3002<\/p>\n<p>\u200c\u5173\u952e\u7ed3\u8bba\u200c&#xff1a;IOC\u5bb9\u5668\u901a\u8fc7\u200c\u5143\u6570\u636e\u9a71\u52a8\u200c&#xff08;BeanDefinition&#xff09;\u3001\u200c\u53cd\u5c04\u52a8\u6001\u4ee3\u7406\u200c\u53ca\u200c\u5e76\u53d1\u63a7\u5236\u200c&#xff0c;\u5b9e\u73b0\u4e0e\u4f20\u7edf\u5de5\u5382\u6a21\u5f0f\u672c\u8d28\u5dee\u5f02\u7684\u89e3\u8026\u4e0e\u81ea\u52a8\u5316\u7ba1\u7406\u3002<\/p>\n<p>3.\u6027\u80fd\u4f18\u5316\u5b9e\u8df5&#xff1a;<\/p>\n<ul>\n<li>\n<p>&#064;Lazy\u6ce8\u89e3\u5728\u4f9d\u8d56\u73af\u573a\u666f\u4e0b\u7684\u5e94\u7528<\/p>\n<\/li>\n<\/ul>\n<li>\n<p>\u200c\u4f9d\u8d56\u73af\u95ee\u9898\u672c\u8d28\u200c \u5f53Bean A\u4f9d\u8d56Bean B&#xff0c;\u540c\u65f6Bean B\u53c8\u4f9d\u8d56Bean A\u65f6&#xff0c;Spring\u9ed8\u8ba4\u7684\u7acb\u5373\u521d\u59cb\u5316\u7b56\u7565\u4f1a\u5bfc\u81f4\u5faa\u73af\u4f9d\u8d56\u5f02\u5e38\u3002<\/p>\n<\/li>\n<li>\n<p>\u200c&#064;Lazy\u7684\u89e3\u51b3\u65b9\u6848\u200c<\/p>\n<ul>\n<li>\u5728\u4efb\u610f\u4e00\u73af\u6dfb\u52a0&#064;Lazy&#xff0c;\u5ef6\u8fdf\u5176\u4e2d\u4e00\u4e2aBean\u7684\u521d\u59cb\u5316&#xff0c;\u6253\u7834\u5faa\u73af\u94fe&#xff1a; &#064;Service<br \/>\npublic class ServiceA {<br \/>\n    &#064;Autowired &#064;Lazy  \/\/ \u5ef6\u8fdf\u6ce8\u5165ServiceB<br \/>\n    private ServiceB serviceB;<br \/>\n}<\/p>\n<\/li>\n<li>\u5e95\u5c42\u901a\u8fc7\u4ee3\u7406\u5bf9\u8c61\u4e34\u65f6\u5360\u4f4d&#xff0c;\u5b9e\u9645\u8c03\u7528\u65f6\u89e6\u53d1\u76ee\u6807Bean\u521d\u59cb\u5316\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200c\u4e0e\u4f5c\u7528\u57df\u7684\u534f\u540c\u200c<\/p>\n<table>\n<tr>\u4f5c\u7528\u57df&#064;Lazy\u6548\u679c<\/tr>\n<tbody>\n<tr>\n<td style=\"text-align:center\">Singleton<\/td>\n<td style=\"text-align:center\">\u5168\u5c40\u5ef6\u8fdf\u5230\u9996\u6b21\u4f7f\u7528&#xff08;\u4ec5\u4e00\u6b21\u521d\u59cb\u5316&#xff09;<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">Prototype<\/td>\n<td style=\"text-align:center\">\u6bcf\u6b21getBean()\u65f6\u65b0\u5efa&#xff08;\u65e0\u4f18\u5316\u610f\u4e49&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>\n<p>\u200c\u6ce8\u610f\u4e8b\u9879\u200c<\/p>\n<ul>\n<li>\u907f\u514d\u5728&#064;Configuration\u7c7b\u4e2d\u6df7\u7528&#064;Lazy\u4e0e&#064;Bean&#xff0c;\u53ef\u80fd\u5bfc\u81f4\u4ee3\u7406\u5c42\u7ea7\u6df7\u4e71\u3002<\/li>\n<li>\u4f9d\u8d56\u73af\u573a\u666f\u4e0b\u9700\u786e\u4fdd\u81f3\u5c11\u4e00\u4e2aBean\u975e\u5ef6\u8fdf\u52a0\u8f7d&#xff0c;\u5426\u5219\u53ef\u80fd\u5f15\u53d1BeanCurrentlyInCreationException\u3002<\/li>\n<\/ul>\n<\/li>\n<ul>\n<li>\n<p>BeanPostProcessor\u5b9e\u73b0\u81ea\u5b9a\u4e49\u521d\u59cb\u5316\u903b\u8f91<\/p>\n<\/li>\n<\/ul>\n<li>\n<p>\u6838\u5fc3\u63a5\u53e3\u65b9\u6cd5\u200c<\/p>\n<p> public interface BeanPostProcessor {<br \/>\n    Object postProcessBeforeInitialization(Object bean, String beanName);<br \/>\n    Object postProcessAfterInitialization(Object bean, String beanName);<br \/>\n}<\/p>\n<ul>\n<li>Before&#xff1a;\u5728&#064;PostConstruct\u4e4b\u524d\u6267\u884c&#xff0c;\u9002\u5408\u4fee\u6539Bean\u5c5e\u6027\u3002<\/li>\n<li>After&#xff1a;\u5728\u4f9d\u8d56\u6ce8\u5165\u5b8c\u6210\u540e\u6267\u884c&#xff0c;\u9002\u5408\u4ee3\u7406\u589e\u5f3a\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200c\u5178\u578b\u5e94\u7528\u573a\u666f\u200c<\/p>\n<ul>\n<li>\u200c\u6027\u80fd\u76d1\u63a7\u200c&#xff1a;\u7edf\u8ba1Bean\u521d\u59cb\u5316\u8017\u65f6\u3002<\/li>\n<li>\u200c\u52a8\u6001\u4ee3\u7406\u200c&#xff1a;\u4e3a\u7279\u5b9a\u63a5\u53e3\u751f\u6210AOP\u4ee3\u7406&#xff08;\u5982&#064;Transactiona\u5e95\u5c42\u5b9e\u73b0&#xff09;\u3002<\/li>\n<li>\u200c\u6761\u4ef6\u5316\u88c5\u914d\u200c&#xff1a;\u6839\u636e\u8fd0\u884c\u65f6\u72b6\u6001\u51b3\u5b9a\u662f\u5426\u6ce8\u5165\u4f9d\u8d56\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200c\u5b9e\u73b0\u793a\u4f8b\u200c<\/p>\n<p> public class CustomInitProcessor implements BeanPostProcessor {<br \/>\n    &#064;Override<br \/>\n    public Object postProcessAfterInitialization(Object bean, String beanName) {<br \/>\n        if (bean instanceof ExpensiveService) {<br \/>\n            return Proxy.newProxyInstance(&#8230;); \/\/ \u751f\u6210\u5ef6\u8fdf\u52a0\u8f7d\u4ee3\u7406<br \/>\n        }<br \/>\n        return bean;<br \/>\n    }<br \/>\n}<\/p>\n<\/li>\n<li>\n<p>\u200c\u4e0e&#064;Lazy\u7684\u534f\u540c\u4f18\u5316\u200c<\/p>\n<ul>\n<li>\u901a\u8fc7BeanPostProcessor\u52a8\u6001\u8bc6\u522b\u9ad8\u5f00\u9500Bean\u5e76\u81ea\u52a8\u6dfb\u52a0&#064;Lazy\u7b49\u6548\u903b\u8f91\u3002<\/li>\n<li>\u907f\u514d\u786c\u7f16\u7801&#064;Lazy&#xff0c;\u5b9e\u73b0\u66f4\u7075\u6d3b\u7684\u5ef6\u8fdf\u7b56\u7565\u3002<\/li>\n<\/ul>\n<\/li>\n<p>\u7efc\u5408\u4f18\u5316\u5efa\u8bae<\/p>\n<li>\u200c\u4f9d\u8d56\u73af\u4f18\u5148\u4f7f\u7528\u6784\u9020\u5668\u6ce8\u5165&#043;&#064;Lazy\u200c&#xff0c;\u800c\u975esetter\u6ce8\u5165&#xff0c;\u4fdd\u6301\u4ee3\u7801\u53ef\u6d4b\u8bd5\u6027\u3002<\/li>\n<li>\u200cBeanPostProcessor\u5e94\u6ce8\u518c\u4e3a\u6700\u9ad8\u4f18\u5148\u7ea7\u200c&#xff08;\u5b9e\u73b0PriorityOrdered\u63a5\u53e3&#xff09;&#xff0c;\u786e\u4fdd\u65e9\u4e8e\u5176\u4ed6\u5904\u7406\u5668\u6267\u884c\u3002<\/li>\n<li>\u200c\u751f\u4ea7\u73af\u5883\u76d1\u63a7\u200c&#xff1a;\u7ed3\u5408Spring Boot Actuator\u7684\/beans\u7aef\u70b9\u5206\u6790\u521d\u59cb\u5316\u987a\u5e8f\u3002<\/li>\n<h4 style=\"background-color:transparent\">\ufe0f&#x1f331;\u751f\u547d\u5468\u671f\u7ba1\u7406\u56fe\u793a<\/h4>\n<p>graph LR:<\/p>\n<p>\u00a0 \u00a0 \u00a0\u00a0<\/p>\n<\/p>\n<p>A[\u5bb9\u5668\u542f\u52a8\u9636\u6bb5] &#8211;&gt; B[\u52a0\u8f7d\u914d\u7f6e\u4fe1\u606f]<\/p>\n<p>B &#8211;&gt; C[\u89e3\u6790Bean\u5b9a\u4e49 \u2192 BeanDefinition]<\/p>\n<p>C &#8211;&gt; D[\u6ce8\u518cBeanDefinition\u5230\u5bb9\u5668]<\/p>\n<p>D &#8211;&gt; E[\u5e94\u7528BeanFactoryPostProcessor]<\/p>\n<p>E &#8211;&gt; F[Bean\u5b9e\u4f8b\u5316\u9636\u6bb5]<\/p>\n<p>F &#8211;&gt; G[\u68c0\u67e5Bean\u4f5c\u7528\u57df\u4e0e\u7f13\u5b58]<\/p>\n<p>G &#8211;&gt; H[\u53cd\u5c04\u521b\u5efaBean\u5b9e\u4f8b]<\/p>\n<p>H &#8211;&gt; I[\u4f9d\u8d56\u6ce8\u5165&#xff1a; &#064;Autowired\/&#064;Resource]<\/p>\n<p>I &#8211;&gt; J[Aware\u63a5\u53e3\u56de\u8c03&#xff1a; BeanNameAware\/BeanFactoryAware]<\/p>\n<p>J &#8211;&gt; K[BeanPostProcessor\u524d\u7f6e\u5904\u7406]<\/p>\n<p>K &#8211;&gt; L[\u521d\u59cb\u5316\u9636\u6bb5]<\/p>\n<p>L &#8211;&gt; M1[\u6267\u884c&#064;PostConstruct]\u00a0<\/p>\n<p>L &#8211;&gt; M2[InitializingBean.afterPropertiesSet]<\/p>\n<p>L &#8211;&gt; M3[\u8c03\u7528\u81ea\u5b9a\u4e49init-method]<\/p>\n<p>L &#8211;&gt; N[BeanPostProcessor\u540e\u7f6e\u5904\u7406]<\/p>\n<p>N &#8211;&gt; O[Bean\u5c31\u7eea \u2192 \u52a0\u5165\u5355\u4f8b\u6c60]<\/p>\n<p>O &#8211;&gt; P[\u8fd0\u884c\u671f\u4f7f\u7528] P &#8211;&gt; Q[\u5bb9\u5668\u5173\u95ed] Q &#8211;&gt; R[\u9500\u6bc1\u9636\u6bb5] R &#8211;&gt; S1[\u6267\u884c&#064;PreDestroy] R &#8211;&gt; S2[DisposableBean.destroy] R &#8211;&gt; S3[\u8c03\u7528\u81ea\u5b9a\u4e49] \u00a0<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"267\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811032407-6899625778d1c.png\" width=\"519\" \/><\/p>\n<h4 style=\"background-color:transparent\">\ufe0f \u2699\u914d\u7f6e\u89c4\u8303\u5efa\u8bae<\/h4>\n<ul>\n<li>\n<p>\u53cd\u6a21\u5f0f&#xff1a;\u6df7\u5408\u6ce8\u5165\u65b9\u5f0f\u5f15\u53d1\u7684\u7a7a\u6307\u9488\u95ee\u9898<\/p>\n<\/li>\n<li>\n<p>\u6700\u4f73\u5b9e\u8df5&#xff1a;\u5f3a\u5236\u4f9d\u8d56\u63a8\u8350\u4f7f\u7528\u6784\u9020\u5668\u6ce8\u5165<\/p>\n<\/li>\n<\/ul>\n<p>\u6784\u9020\u5668\u6ce8\u5165\u5f3a\u5236\u89c4\u8303<\/p>\n<li>\n<p>\u200c\u6838\u5fc3\u4f18\u52bf\u200c<\/p>\n<ul>\n<li>\u4fdd\u8bc1\u4f9d\u8d56\u4e0d\u53ef\u53d8&#xff08;final\u4fee\u9970&#xff09;<\/li>\n<li>\u907f\u514dNPE\u98ce\u9669&#xff08;\u5bb9\u5668\u542f\u52a8\u65f6\u5b8c\u6210\u4f9d\u8d56\u68c0\u67e5&#xff09;<\/li>\n<li>\u663e\u5f0f\u58f0\u660e\u5f3a\u4f9d\u8d56\u5173\u7cfb&#xff0c;\u63d0\u5347\u4ee3\u7801\u53ef\u8bfb\u6027<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200c\u6807\u51c6\u5b9e\u73b0\u200c<\/p>\n<p> &#064;Service<br \/>\npublic class OrderService {<br \/>\n    private final PaymentGateway gateway; \/\/ final\u786e\u4fdd\u4e0d\u53ef\u53d8<\/p>\n<p>    &#064;Autowired \/\/ Spring 4.3&#043;\u53ef\u7701\u7565<br \/>\n    public OrderService(PaymentGateway gateway) {<br \/>\n        this.gateway &#061; gateway; \/\/ \u4f9d\u8d56\u975e\u7a7a\u6821\u9a8c\u53ef\u5728\u6b64\u6267\u884c<br \/>\n    }<br \/>\n}<\/p>\n<\/li>\n<p>\u6df7\u5408\u6ce8\u5165\u53cd\u6a21\u5f0f\u98ce\u9669<\/p>\n<li>\n<p>\u200c\u5178\u578b\u95ee\u9898\u573a\u666f\u200c<\/p>\n<p> &#064;Controller<br \/>\npublic class UserController {<br \/>\n    &#064;Autowired \/\/ \u5b57\u6bb5\u6ce8\u5165<br \/>\n    private UserService userService;<\/p>\n<p>    private AuditService auditService; \/\/ setter\u6ce8\u5165<\/p>\n<p>    public void process() {<br \/>\n        auditService.log(); \/\/ NPE\u98ce\u9669&#xff08;\u672a\u901a\u8fc7setter\u6ce8\u5165\u65f6&#xff09;<br \/>\n    }<\/p>\n<p>    &#064;Autowired<br \/>\n    public void setAuditService(AuditService s) {<br \/>\n        this.auditService &#061; s;<br \/>\n    }<br \/>\n}<\/p>\n<\/li>\n<p>\u200c\u98ce\u9669\u70b9\u200c&#xff1a;\u5b57\u6bb5\u6ce8\u5165\u4e0esetter\u6ce8\u5165\u6df7\u7528\u5bfc\u81f4\u90e8\u5206\u4f9d\u8d56\u672a\u521d\u59cb\u5316<\/p>\n<li>\n<p>\u200c\u89e3\u51b3\u65b9\u6848\u200c<\/p>\n<ul>\n<li>\u7edf\u4e00\u4f7f\u7528\u6784\u9020\u5668\u6ce8\u5165<\/li>\n<li>\u5bf9\u53ef\u9009\u4f9d\u8d56\u91c7\u7528Optional\u5305\u88c5\u6216&#064;Nullable\u6ce8\u89e3<\/li>\n<\/ul>\n<\/li>\n<p>\u9ad8\u7ea7\u914d\u7f6e\u5efa\u8bae<\/p>\n<li>\n<p>\u200c\u5faa\u73af\u4f9d\u8d56\u5904\u7406\u200c<\/p>\n<table>\n<tr>\u65b9\u6848\u9002\u7528\u573a\u666f\u5b9e\u73b0\u65b9\u5f0f<\/tr>\n<tbody>\n<tr>\n<td style=\"text-align:center\">&#064;Lazy<\/td>\n<td style=\"text-align:center\">\u5355\u4f8bBean\u5faa\u73af\u5f15\u7528<\/td>\n<td style=\"text-align:center\">\u5728\u6784\u9020\u53c2\u6570\u6dfb\u52a0&#064;Lazy\u5ef6\u8fdf\u521d\u59cb\u5316<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">Setter\/\u5b57\u6bb5\u6ce8\u5165<\/td>\n<td style=\"text-align:center\">\u4e0d\u63a8\u8350&#xff08;\u7834\u574f\u4e0d\u53ef\u53d8\u6027&#xff09;<\/td>\n<td style=\"text-align:center\">\u4ec5\u4f5c\u4e34\u65f6\u89e3\u51b3\u65b9\u6848<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>\n<p>\u200cBean\u4f5c\u7528\u57df\u89c4\u8303\u200c<\/p>\n<ul>\n<li>\u65e0\u72b6\u6001\u670d\u52a1\u4f7f\u7528Singleton&#xff08;\u9ed8\u8ba4&#xff09;<\/li>\n<li>\u6709\u72b6\u6001\u7ec4\u4ef6\u4f7f\u7528Prototype\u6216\u8bf7\u6c42\u7ea7\u4f5c\u7528\u57df<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200cAOP\u4ee3\u7406\u517c\u5bb9\u6027\u200c<\/p>\n<ul>\n<li>\u6784\u9020\u5668\u6ce8\u5165\u5929\u7136\u652f\u6301JDK\u52a8\u6001\u4ee3\u7406\u548cCGLIB<\/li>\n<li>\u5b57\u6bb5\u6ce8\u5165\u53ef\u80fd\u5bfc\u81f4\u4ee3\u7406\u5931\u6548&#xff08;\u5c24\u5176CGLIB&#xff09;<\/li>\n<\/ul>\n<\/li>\n<p>\u5de5\u7a0b\u5316\u68c0\u67e5\u7b56\u7565<\/p>\n<p>\u200c\u9759\u6001\u4ee3\u7801\u5206\u6790\u200c<\/p>\n<p> &lt;!&#8211; SpotBugs\u89c4\u5219\u793a\u4f8b &#8211;&gt;<br \/>\n&lt;dependency&gt;<br \/>\n    &lt;groupId&gt;com.github.spotbugs&lt;\/groupId&gt;<br \/>\n    &lt;artifactId&gt;spotbugs-annotations&lt;\/artifactId&gt;<br \/>\n    &lt;version&gt;4.7.3&lt;\/version&gt;<br \/>\n&lt;\/dependency&gt;<\/p>\n<p>\u68c0\u6d4b&#064;Autowired\u5b57\u6bb5\u6ce8\u5165\u7684\u4f7f\u7528<\/p>\n<p>\u200c\u5355\u5143\u6d4b\u8bd5\u4fdd\u969c\u200c<\/p>\n<p> &#064;SpringBootTest<br \/>\nclass OrderServiceTest {<br \/>\n    &#064;Test<br \/>\n    void shouldThrowWhenDependencyNull() {<br \/>\n        assertThrows(BeanCreationException.class,<br \/>\n            () -&gt; new OrderService(null));<br \/>\n    }<br \/>\n}<\/p>\n<h4><\/h4>\n<hr \/>\n<h3 style=\"background-color:transparent\">\u2728 \u7b2c\u4e8c\u7ae0&#xff1a;AOP\u2014\u2014\u975e\u4fb5\u5165\u5f0f\u589e\u5f3a(\u4ee3\u7801\u754c\u7684&#034;\u7f8e\u989c\u76f8\u673a&#034;)<\/h3>\n<h4>&#x1f4a1; \u7075\u9b42\u4e4b\u95ee&#xff1a;\u4e3a\u4ec0\u4e48\u8981\u7528AOP&#xff1f;<\/h4>\n<p>\u5f53\u8001\u677f\u8981\u6c42\u5728\u6240\u6709\u65b9\u6cd5\u52a0\u65e5\u5fd7\u65f6&#xff1a;<\/p>\n<ul>\n<li>\n<p>OOP\u505a\u6cd5&#xff1a;\u6bcf\u4e2a\u65b9\u6cd5\u91cc\u5199log.info()&#xff08;\u91cd\u590d\u52b3\u52a8&#xff09;<\/p>\n<\/li>\n<li>\n<p>AOP\u505a\u6cd5&#xff1a;\u58f0\u660e&#034;\u51e1Controller\u5c42\u65b9\u6cd5\u90fd\u8981\u81ea\u52a8\u62cd\u7167\u7559\u5ff5&#034;<\/p>\n<\/li>\n<\/ul>\n<h4>\u7535\u5f71\u62cd\u6444\u7248\u7406\u89e3<\/h4>\n<p>\u628a\u7cfb\u7edf\u770b\u4f5c\u7535\u5f71\u5267\u7ec4&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4e3b\u6f14&#xff1a;\u6838\u5fc3\u4e1a\u52a1\u903b\u8f91&#xff08;Service\u65b9\u6cd5&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u66ff\u8eab&#xff1a;\u589e\u5f3a\u903b\u8f91&#xff08;Advice&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u5bfc\u6f14&#xff1a;\u51b3\u5b9a\u4ec0\u4e48\u65f6\u5019\u7528\u66ff\u8eab&#xff08;Pointcut&#xff09;<\/p>\n<\/li>\n<\/ul>\n<p>&#064;Aspect<br \/>\npublic class LogAspect {<br \/>\n    \/\/ \u5b9a\u4e49\u62cd\u6444\u65f6\u673a&#xff1a;\u6240\u6709&#064;GetMapping\u573a\u666f<br \/>\n    &#064;Pointcut(&#034;&#064;annotation(GetMapping)&#034;)<br \/>\n    public void logPointcut() {}<br \/>\n    \/\/ \u5f00\u62cd\u524d\u6253\u677f&#xff08;\u524d\u7f6e\u901a\u77e5&#xff09;<br \/>\n    &#064;Before(&#034;logPointcut()&#034;)<br \/>\n    public void beforeAction(JoinPoint jp) {<br \/>\n        System.out.println(&#034;Action! Method: &#034; &#043; jp.getSignature());<br \/>\n    }<br \/>\n} <\/p>\n<h4>&#x1f3af; \u5fc5\u77e5\u6982\u5ff5\u4e09\u8fde<\/h4>\n<li>\n<p>JoinPoint&#xff1a;\u88ab\u62e6\u622a\u7684&#034;\u62cd\u6444\u73b0\u573a&#034;<\/p>\n<\/li>\n<li>\n<p>Advice&#xff1a;\u4e94\u79cd&#034;\u7279\u6548\u5904\u7406&#034;&#xff1a;<\/p>\n<ul>\n<li>\n<p>&#064;Before&#xff08;\u5f00\u573a\u767d&#xff09;<\/p>\n<\/li>\n<li>\n<p>&#064;After&#xff08;\u6740\u9752\u955c\u5934&#xff09;<\/p>\n<\/li>\n<li>\n<p>&#064;Around&#xff08;\u5168\u7a0b\u8ddf\u62cd&#xff09;<\/p>\n<\/li>\n<li>\n<p>&#064;AfterReturning&#xff08;\u5b8c\u7f8e\u6536\u5b98&#xff09;<\/p>\n<\/li>\n<li>\n<p>&#064;AfterThrowing&#xff08;NG\u955c\u5934&#xff09;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u52a8\u6001\u4ee3\u7406&#xff1a;<\/p>\n<ul>\n<li>\n<p>JDK\u4ee3\u7406&#xff1a;\u8981\u6c42\u6f14\u5458\u5fc5\u987b\u6709\u63a5\u53e3&#xff08;\u50cf\u7b7e\u7ea6\u827a\u4eba&#xff09;<\/p>\n<\/li>\n<li>\n<p>CGLIB&#xff1a;\u7d20\u4eba\u4e5f\u80fd\u76f4\u63a5\u5305\u88c5&#xff08;\u7ee7\u627f\u65b9\u5f0f&#xff09;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<h4 style=\"background-color:transparent\">&#x1f527; \u6027\u80fd\u8c03\u4f18\u5b9e\u6218<\/h4>\n<\/p>\n<h5 style=\"background-color:transparent\">\u4e00\u3001\u5207\u9762\u6267\u884c\u987a\u5e8f\u63a7\u5236<\/h5>\n<li>\n<p>\u200c\u591a\u5207\u9762\u4f18\u5148\u7ea7\u7ba1\u7406\u200c<\/p>\n<p> &#064;Aspect<br \/>\n&#064;Order(1) \/\/ \u5148\u6267\u884c<br \/>\npublic class LoggingAspect { &#8230; }<\/p>\n<p>&#064;Aspect<br \/>\n&#064;Order(2) \/\/ \u540e\u6267\u884c<br \/>\npublic class SecurityAspect { &#8230; }<\/p>\n<ul>\n<li>\u4f7f\u7528&#064;Order\u6ce8\u89e3\u660e\u786e\u6307\u5b9a\u5207\u9762\u6267\u884c\u987a\u5e8f&#xff08;\u6570\u503c\u8d8a\u5c0f\u4f18\u5148\u7ea7\u8d8a\u9ad8&#xff09;<\/li>\n<li>\u5178\u578b\u573a\u666f&#xff1a;\u9a8c\u8bc1\u5207\u9762\u9700\u5148\u4e8e\u65e5\u5fd7\u5207\u9762\u6267\u884c<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200c\u901a\u77e5\u7c7b\u578b\u6267\u884c\u987a\u5e8f\u200c<\/p>\n<p>  \u5355\u5207\u9762\u5185&#xff1a;<br \/>\n&#064;Around \u2192 &#064;Before \u2192 \u76ee\u6807\u65b9\u6cd5<br \/>\n\u2192 &#064;AfterReturning\/&#064;AfterThrowing \u2192 &#064;After \u2192 &#064;Around<\/p>\n<\/li>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u73af\u7ed5\u901a\u77e5\u9700\u624b\u52a8\u8c03\u7528proceed()\u89e6\u53d1\u540e\u7eed\u6d41\u7a0b <\/p>\n<h5>\u4e8c\u3001\u5207\u5165\u70b9\u8868\u8fbe\u5f0f\u4f18\u5316<\/h5>\n<ul>\n<li>\n<p>\u200c\u8868\u8fbe\u5f0f\u7c7b\u578b\u9009\u62e9\u200c<\/p>\n<table>\n<tr>\u8868\u8fbe\u5f0f\u7c7b\u578b\u9002\u7528\u573a\u666f\u6027\u80fd\u5f71\u54cd<\/tr>\n<tbody>\n<tr>\n<td style=\"text-align:center\">execution()<\/td>\n<td style=\"text-align:center\">\u7cbe\u786e\u5339\u914d\u65b9\u6cd5\u7b7e\u540d&#xff08;\u5305&#043;\u7c7b&#043;\u65b9\u6cd5&#xff09;<\/td>\n<td style=\"text-align:center\">\u9ad8&#xff08;\u9700\u626b\u63cf\u5b57\u8282\u7801&#xff09;<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">&#064;annotation()<\/td>\n<td style=\"text-align:center\">\u901a\u8fc7\u6ce8\u89e3\u6807\u8bb0\u76ee\u6807\u65b9\u6cd5<\/td>\n<td style=\"text-align:center\">\u4e2d&#xff08;\u9700\u53cd\u5c04\u68c0\u67e5&#xff09;<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">within()<\/td>\n<td style=\"text-align:center\">\u5339\u914d\u7c7b\u7ea7\u522b<\/td>\n<td style=\"text-align:center\">\u4f4e&#xff08;\u7c7b\u52a0\u8f7d\u65f6\u8fc7\u6ee4&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>\n<p>\u200c\u6027\u80fd\u4f18\u5316\u6280\u5de7\u200c<\/p>\n<ul>\n<li>\u907f\u514d\u5bbd\u6cdb\u5339\u914d&#xff08;\u5982*.*(..)&#xff09;&#xff0c;\u9650\u5b9a\u5230\u5177\u4f53\u5305\u8def\u5f84<\/li>\n<li>\u590d\u7528\u5207\u5165\u70b9\u5b9a\u4e49&#xff1a;  &#064;Pointcut(&#034;execution(* com.example.service.*.*(..))&#034;)<br \/>\npublic void serviceLayer() {}<\/p>\n<p>&#064;Before(&#034;serviceLayer()&#034;)<br \/>\npublic void logBefore() { &#8230; }<\/p>\n<\/li>\n<li>\u4f18\u5148\u4f7f\u7528&#064;annotation\u51cf\u5c11\u5339\u914d\u8303\u56f4<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5 style=\"background-color:transparent\">\u4e09\u3001\u4ee3\u7406\u673a\u5236\u8c03\u4f18<\/h5>\n<li>\n<p>\u200c\u5f3a\u5236CGLIB\u4ee3\u7406\u200c<\/p>\n<p> # \u89e3\u51b3JDK\u52a8\u6001\u4ee3\u7406\u9700\u63a5\u53e3\u7684\u9650\u5236<br \/>\nspring.aop.proxy-target-class&#061;true<\/p>\n<p> CGLIB\u6027\u80fd\u5f00\u9500\u7565\u9ad8\u4f46\u529f\u80fd\u66f4\u5168\u9762<\/li>\n<li>\n<p>\u200c\u5207\u9762\u61d2\u52a0\u8f7d\u200c<\/p>\n<p> &#064;Aspect<br \/>\n&#064;Lazy \/\/ \u5ef6\u8fdf\u521d\u59cb\u5316\u5207\u9762\u5b9e\u4f8b<br \/>\npublic class HeavyAspect { &#8230; }<\/p>\n<\/li>\n<h5 style=\"background-color:transparent\">\u56db\u3001\u5b9e\u6218\u6848\u4f8b&#xff1a;\u63a5\u53e3\u8017\u65f6\u76d1\u63a7<\/h5>\n<li>\u200c\u81ea\u5b9a\u4e49\u6ce8\u89e3\u65b9\u6848\u200c  &#064;Target(ElementType.METHOD)<br \/>\n&#064;Retention(RetentionPolicy.RUNTIME)<br \/>\npublic &#064;interface TrackExecutionTime {}<\/p>\n<\/li>\n<li>\u200c\u9ad8\u6548\u5207\u9762\u5b9e\u73b0\u200c  &#064;Aspect<br \/>\n&#064;Component<br \/>\npublic class ExecutionTimeAspect {<br \/>\n    private static final Logger log &#061; LoggerFactory.getLogger(ExecutionTimeAspect.class);<\/p>\n<p>    &#064;Around(&#034;&#064;annotation(TrackExecutionTime)&#034;)<br \/>\n    public Object trackTime(ProceedingJoinPoint pjp) throws Throwable {<br \/>\n        long start &#061; System.nanoTime();<br \/>\n        try {<br \/>\n            return pjp.proceed();<br \/>\n        } finally {<br \/>\n            log.debug(&#034;Method {} executed in {} ns&#034;,<br \/>\n                pjp.getSignature(), System.nanoTime() &#8211; start);<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p> \u4f7f\u7528\u7eb3\u79d2\u7ea7\u8ba1\u65f6\u51cf\u5c11\u8bef\u5dee<\/li>\n<h5>\u4e94\u3001\u5e38\u89c1\u9677\u9631\u89c4\u907f<\/h5>\n<li>\n<p>\u200cController\u5c42\u5207\u9762\u4f18\u5316\u200c<\/p>\n<ul>\n<li>\u907f\u514d\u76f4\u63a5\u62e6\u622aController\u7c7b&#xff0c;\u6539\u4e3a\u589e\u5f3aSpring\u6846\u67b6\u8c03\u7528\u5165\u53e3<\/li>\n<li>\u793a\u4f8b\u53cd\u6a21\u5f0f&#xff1a; \/\/ \u4e0d\u63a8\u8350&#xff08;\u6027\u80fd\u654f\u611f&#xff09;<br \/>\n&#064;Before(&#034;execution(* com.example.web..*.*(..))&#034;)<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200c\u5faa\u73af\u4f9d\u8d56\u5904\u7406\u200c<\/p>\n<\/li>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5207\u9762\u4f9d\u8d56\u5176\u4ed6Bean\u65f6\u9700\u914d\u5408&#064;Lazy\u6253\u7834\u5faa\u73af\u94fe<\/p>\n<h4>&#x1f4ca; \u4ee3\u7406\u6280\u672f\u9009\u578b\u6307\u5357<\/h4>\n<table>\n<tbody>\n<tr>\n<p style=\"text-align:center\">\u7279\u6027<\/p>\n<p style=\"text-align:center\">JDK\u52a8\u6001\u4ee3\u7406<\/p>\n<p style=\"text-align:center\">CGLIB<\/p>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u5b9e\u73b0\u673a\u5236<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u63a5\u53e3\u4ee3\u7406<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u5b50\u7c7b\u7ee7\u627f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u9002\u7528\u573a\u666f<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u63a5\u53e3\u5b8c\u5907\u7684\u7cfb\u7edf<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u9057\u7559\u4ee3\u7801\u6539\u9020<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u6027\u80fd\u7279\u70b9<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u8c03\u7528\u6548\u7387\u9ad8<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u751f\u6210\u901f\u5ea6\u5feb<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">Spring\u7b56\u7565<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u9ed8\u8ba4\u65b9\u6848<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u8865\u5145\u65b9\u6848<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>&#x1f4a5; \u5178\u578b\u95ee\u9898\u573a\u666f<\/h4>\n<p>\/\/ \u5185\u90e8\u8c03\u7528\u5bfc\u81f4\u7684\u4ee3\u7406\u5931\u6548<br \/>\npublic class PaymentService {<br \/>\n    public void process() { verifyAccount(); \/\/ \u7ed5\u8fc7\u4e8b\u52a1\u4ee3\u7406 } <\/p>\n<p>    &#064;Transactional<br \/>\n    void verifyAccount() {&#8230;}<br \/>\n} <\/p>\n<p>\u89e3\u51b3\u65b9\u6848&#xff1a;\u901a\u8fc7ApplicationContext\u83b7\u53d6\u4ee3\u7406\u5b9e\u4f8b<\/p>\n<hr \/>\n<h3 style=\"background-color:transparent\">&#x1f4bc; \u7b2c\u4e09\u7ae0&#xff1a;\u4e8b\u52a1\u7ba1\u7406\u2014\u2014\u6570\u636e\u4e00\u81f4\u6027\u4fdd\u969c(\u6570\u636e\u5e93\u754c\u7684&#034;\u652f\u4ed8\u5b9d&#034;)<\/h3>\n<h4>\u2753 \u9762\u8bd5\u6b7b\u4ea1\u95ee\u9898&#xff1a;\u4e8b\u52a1\u4f20\u64ad\u673a\u5236<\/h4>\n<p>\u5f53\u88ab\u95ee\u5230\u4f20\u64ad\u884c\u4e3a\u65f6&#xff0c;\u5176\u5b9e\u5728\u8003\u5bdf&#xff1a;<\/p>\n<li>\n<p>\u591a\u4e2a\u4e8b\u52a1\u65b9\u6cd5\u4e92\u76f8\u8c03\u7528\u65f6\u7684\u8fb9\u754c\u63a7\u5236<\/p>\n<\/li>\n<li>\n<p>\u5bf9ACID\u539f\u5219\u7684\u5b9e\u9645\u5e94\u7528\u80fd\u529b<\/p>\n<\/li>\n<p>\u805a\u9910\u4e70\u5355\u7c7b\u6bd4<\/p>\n<p>\u628a\u4e8b\u52a1\u4f20\u64ad\u6bd4\u4f5c\u670b\u53cb\u805a\u9910&#xff1a;<\/p>\n<ul>\n<li>\n<p>REQUIRED&#xff08;\u9ed8\u8ba4&#xff09;&#xff1a;\u6709\u4eba\u4e70\u5355\u5c31\u8ddf\u7740\u5403&#xff0c;\u6ca1\u4eba\u4e70\u5c31\u81ea\u5df1\u5f00\u5355<\/p>\n<\/li>\n<li>\n<p>REQUIRES_NEW&#xff1a;\u4e0d\u7ba1\u6709\u6ca1\u6709\u4eba\u4e70\u5355&#xff0c;\u81ea\u5df1\u53e6\u5f00\u4e00\u684c<\/p>\n<\/li>\n<li>\n<p>NESTED&#xff1a;\u8bb0\u5b50\u8d26\u5355&#xff0c;\u4e3b\u5355\u5931\u8d25\u5c31\u53d6\u6d88<\/p>\n<\/li>\n<li>\n<p>NOT_SUPPORTED&#xff1a;AA\u5236&#xff0c;\u4e0d\u53c2\u4e0e\u96c6\u4f53\u4e70\u5355<\/p>\n<\/li>\n<\/ul>\n<p>&#064;Transactional(propagation &#061; Propagation.REQUIRED)<br \/>\npublic void groupDinner() {<br \/>\n    \/\/ \u5982\u679c\u5df2\u6709\u4e8b\u52a1\u5c31\u52a0\u5165&#xff0c;\u6ca1\u6709\u5c31\u521b\u5efa<br \/>\n} <\/p>\n<p>&#064;Transactional(propagation &#061; Propagation.REQUIRES_NEW)<br \/>\npublic void privateRoom() {<br \/>\n    \/\/ \u5fc5\u987b\u5f00\u65b0\u5305\u95f4&#xff0c;\u4e0d\u53d7\u5916\u754c\u5f71\u54cd<br \/>\n} <\/p>\n<h4>&#x1f4a3; \u4e8b\u52a1\u5931\u6548\u7684\u4e94\u5927\u5751<\/h4>\n<li>\n<p>\u65b9\u6cd5\u975epublic&#xff08;\u5305\u53a2\u95e8\u9501\u4e86&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u81ea\u8c03\u7528\u95ee\u9898&#xff08;\u81ea\u5df1\u53eb\u81ea\u5df1\u5403\u996d&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u5f02\u5e38\u7c7b\u578b\u4e0d\u5339\u914d&#xff08;\u5403\u51fa\u866b\u5b50\u4f46\u53ea\u8bf4&#034;\u4e0d\u597d\u5403&#034;&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u5e93\u5f15\u64ce\u4e0d\u652f\u6301&#xff08;\u5927\u6392\u6863\u6ca1\u6709\u53d1\u7968&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u672a\u542f\u7528\u4e8b\u52a1\u7ba1\u7406&#xff08;\u5fd8\u8bb0\u5e26\u94b1\u5305&#xff09;<\/p>\n<\/li>\n<h5>\u4e00\u3001\u4e8b\u52a1\u57fa\u7840\u6982\u5ff5<\/h5>\n<li>\n<p>\u200cACID\u7279\u6027\u200c<\/p>\n<ul>\n<li>\u200c\u539f\u5b50\u6027 (Atomicity)\u200c&#xff1a;\u4e8b\u52a1\u5185\u64cd\u4f5c\u8981\u4e48\u5168\u90e8\u6210\u529f&#xff0c;\u8981\u4e48\u5168\u90e8\u5931\u8d25\u56de\u6eda\u3002<\/li>\n<li>\u200c\u4e00\u81f4\u6027 (Consistency)\u200c&#xff1a;\u4e8b\u52a1\u6267\u884c\u524d\u540e\u6570\u636e\u72b6\u6001\u4fdd\u6301\u4e00\u81f4&#xff08;\u5982\u8f6c\u8d26\u524d\u540e\u603b\u91d1\u989d\u4e0d\u53d8&#xff09;\u3002<\/li>\n<li>\u200c\u9694\u79bb\u6027 (Isolation)\u200c&#xff1a;\u5e76\u53d1\u4e8b\u52a1\u95f4\u4e92\u4e0d\u5e72\u6270&#xff0c;\u9632\u6b62\u810f\u8bfb\u3001\u5e7b\u8bfb\u7b49\u95ee\u9898\u3002<\/li>\n<li>\u200c\u6301\u4e45\u6027 (Durability)\u200c&#xff1a;\u4e8b\u52a1\u63d0\u4ea4\u540e\u6570\u636e\u6c38\u4e45\u4fdd\u5b58&#xff0c;\u5373\u4f7f\u7cfb\u7edf\u6545\u969c\u4e5f\u4e0d\u4e22\u5931\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200c\u9694\u79bb\u7ea7\u522b\u200c<\/p>\n<table>\n<tr>\u7ea7\u522b\u810f\u8bfb\u4e0d\u53ef\u91cd\u590d\u8bfb\u5e7b\u8bfb\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td style=\"text-align:center\">READ_UNCOMMITTED<\/td>\n<td style=\"text-align:center\">\u2713<\/td>\n<td style=\"text-align:center\">\u2713<\/td>\n<td style=\"text-align:center\">\u2713<\/td>\n<td style=\"text-align:center\">\u4f4e\u4e00\u81f4\u6027\u8981\u6c42<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">READ_COMMITTED<\/td>\n<td style=\"text-align:center\">\u2717<\/td>\n<td style=\"text-align:center\">\u2713<\/td>\n<td style=\"text-align:center\">\u2713<\/td>\n<td style=\"text-align:center\">\u9ed8\u8ba4\u7ea7\u522b&#xff08;Oracle&#xff09;<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">REPEATABLE_READ<\/td>\n<td style=\"text-align:center\">\u2717<\/td>\n<td style=\"text-align:center\">\u2717<\/td>\n<td style=\"text-align:center\">\u2713<\/td>\n<td style=\"text-align:center\">\u9ed8\u8ba4\u7ea7\u522b&#xff08;MySQL&#xff09;<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">SERIALIZABLE<\/td>\n<td style=\"text-align:center\">\u2717<\/td>\n<td style=\"text-align:center\">\u2717<\/td>\n<td style=\"text-align:center\">\u2717<\/td>\n<td style=\"text-align:center\">\u5f3a\u4e00\u81f4\u6027\u573a\u666f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u901a\u8fc7&#064;Transactional(isolation &#061; Isolation.READ_COMMITTED)\u00a0\u6307\u5b9a\u3002<\/p>\n<\/li>\n<li>\n<p>\u200c\u4f20\u64ad\u884c\u4e3a\u200c<\/p>\n<table>\n<tr>\u884c\u4e3a\u7c7b\u578b\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td style=\"text-align:center\">REQUIRED\u00a0(\u9ed8\u8ba4)<\/td>\n<td style=\"text-align:center\">\u5f53\u524d\u5b58\u5728\u4e8b\u52a1\u5219\u52a0\u5165&#xff0c;\u5426\u5219\u65b0\u5efa\u4e8b\u52a1<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">REQUIRES_NEW<\/td>\n<td style=\"text-align:center\">\u59cb\u7ec8\u65b0\u5efa\u4e8b\u52a1&#xff0c;\u6302\u8d77\u5f53\u524d\u4e8b\u52a1&#xff08;\u72ec\u7acb\u63d0\u4ea4\/\u56de\u6eda&#xff09;<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">SUPPORTS<\/td>\n<td style=\"text-align:center\">\u5f53\u524d\u5b58\u5728\u4e8b\u52a1\u5219\u52a0\u5165&#xff0c;\u5426\u5219\u4ee5\u975e\u4e8b\u52a1\u65b9\u5f0f\u8fd0\u884c<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">NOT_SUPPORTED<\/td>\n<td style=\"text-align:center\">\u4ee5\u975e\u4e8b\u52a1\u65b9\u5f0f\u6267\u884c&#xff0c;\u6302\u8d77\u5f53\u524d\u4e8b\u52a1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<hr \/>\n<h5>\u4e8c\u3001\u4e8b\u52a1\u5b9e\u73b0\u65b9\u5f0f<\/h5>\n<li>\n<p>\u200c\u7f16\u7a0b\u5f0f\u4e8b\u52a1\u200c<\/p>\n<p> TransactionTemplate template &#061; &#8230;;<br \/>\ntemplate.execute(status -&gt; {<br \/>\n    \/\/ \u4e1a\u52a1\u903b\u8f91<br \/>\n    if (error) status.setRollbackOnly(); \/\/ \u624b\u52a8\u56de\u6eda<br \/>\n    return result;<br \/>\n});<\/p>\n<\/li>\n<p>\u200c\u7f3a\u70b9\u200c&#xff1a;\u4ee3\u7801\u4fb5\u5165\u6027\u5f3a&#xff0c;\u9700\u624b\u52a8\u7ba1\u7406\u4e8b\u52a1\u8fb9\u754c\u3002<\/p>\n<li>\n<p>\u200c\u58f0\u660e\u5f0f\u4e8b\u52a1&#xff08;\u63a8\u8350&#xff09;\u200c<\/p>\n<\/li>\n<p>\u200c\u6ce8\u89e3\u9a71\u52a8\u200c&#xff1a;<\/p>\n<p>&#064;Transactional(<br \/>\n    propagation &#061; Propagation.REQUIRED,<br \/>\n    rollbackFor &#061; Exception.class \/\/ \u6307\u5b9a\u5f02\u5e38\u56de\u6eda<br \/>\n)<br \/>\npublic void updateData() { &#8230; }<\/p>\n<p>\u7c7b\u7ea7\u6ce8\u89e3\u4f5c\u7528\u4e8e\u6240\u6709public\u65b9\u6cd5&#xff0c;\u65b9\u6cd5\u7ea7\u6ce8\u89e3\u53ef\u8986\u76d6\u7c7b\u7ea7\u914d\u7f6e\u3002<\/p>\n<p>\u200cXML\u914d\u7f6e\u200c&#xff1a;<\/p>\n<p>&lt;tx:advice id&#061;&#034;txAdvice&#034;&gt;<br \/>\n    &lt;tx:attributes&gt;<br \/>\n        &lt;tx:method name&#061;&#034;update*&#034; propagation&#061;&#034;REQUIRED&#034;\/&gt;<br \/>\n    &lt;\/tx:attributes&gt;<br \/>\n&lt;\/tx:advice&gt;<br \/>\n&lt;aop:config&gt;<br \/>\n    &lt;aop:advisor advice-ref&#061;&#034;txAdvice&#034; pointcut&#061;&#034;execution(* com.service.*.*(..))&#034;\/&gt;<br \/>\n&lt;\/aop:config&gt;<\/p>\n<hr \/>\n<h5>\u4e09\u3001\u6838\u5fc3\u63a5\u53e3<\/h5>\n<p>1\u200c.PlatformTransactionManager\u200c<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4e8b\u52a1\u7ba1\u7406\u6838\u5fc3\u63a5\u53e3&#xff08;\u5982DataSourceTransactionManager\u3001JpaTransactionManager&#xff09;\u3002<\/p>\n<p>2\u200c.TransactionDefinition\u200c<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5b9a\u4e49\u4e8b\u52a1\u5c5e\u6027&#xff08;\u4f20\u64ad\u884c\u4e3a\u3001\u9694\u79bb\u7ea7\u522b\u3001\u8d85\u65f6\u7b49&#xff09;\u3002<\/p>\n<p>3\u200c.TransactionStatus\u200c<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4e8b\u52a1\u8fd0\u884c\u65f6\u72b6\u6001&#xff08;\u662f\u5426\u56de\u6eda\u3001\u662f\u5426\u5b8c\u6210&#xff09;\u3002<\/p>\n<hr \/>\n<h5>\u56db\u3001\u7591\u96be\u89e3\u51b3\u65b9\u6848<\/h5>\n<table>\n<tr>\u95ee\u9898\u539f\u56e0\u89e3\u51b3\u65b9\u6848<\/tr>\n<tbody>\n<tr>\n<td style=\"text-align:center\">\u200c\u4e8b\u52a1\u672a\u751f\u6548\u200c<\/td>\n<td style=\"text-align:center\">\u65b9\u6cd5\u975epublic<\/td>\n<td style=\"text-align:center\">\u4ec5public\u65b9\u6cd5\u652f\u6301\u4e8b\u52a1\u4ee3\u7406<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">\u200c\u5f02\u5e38\u672a\u56de\u6eda\u200c<\/td>\n<td style=\"text-align:center\">\u9ed8\u8ba4\u4ec5\u56de\u6edaRuntimeException<\/td>\n<td style=\"text-align:center\">\u6dfb\u52a0&#064;Transactional(rollbackFor &#061; Exception.class)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">\u200c\u8de8\u65b9\u6cd5\u8c03\u7528\u5931\u6548\u200c<\/td>\n<td style=\"text-align:center\">\u540c\u7c7b\u5185\u975e\u4ee3\u7406\u8c03\u7528<\/td>\n<td style=\"text-align:center\">\u901a\u8fc7AOP\u4e0a\u4e0b\u6587\u8c03\u7528\u6216\u62c6\u5206\u5230\u4e0d\u540c\u7c7b<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">\u200c\u6570\u636e\u5e93\u4e0d\u652f\u6301\u200c<\/td>\n<td style=\"text-align:center\">\u5982MySQL\u7684MyISAM\u5f15\u64ce<\/td>\n<td style=\"text-align:center\">\u5207\u6362\u4e3aInnoDB\u5f15\u64ce<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h5>\u4e94\u3001\u6700\u4f73\u5b9e\u8df5<\/h5>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01\u200c.\u7edf\u4e00\u5f02\u5e38\u56de\u6eda\u200c&#xff1a;<\/p>\n<p>&#064;Transactional(rollbackFor &#061; Exception.class) \/\/ \u8986\u76d6\u6240\u6709\u5f02\u5e38\u7c7b\u578b<br \/>\n&#096;&#096;&#096;:ml-citation{ref&#061;&#034;3&#034; data&#061;&#034;citationList&#034;}  <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u200c.\u7cbe\u7b80\u4e8b\u52a1\u8303\u56f4\u200c&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u907f\u514d\u5728\u4e8b\u52a1\u5185\u6267\u884c\u8017\u65f6\u64cd\u4f5c&#xff08;\u5982\u7f51\u7edc\u8c03\u7528&#xff09;\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a03.\u8bfb\u5199\u5206\u79bb\u4f18\u5316\u200c&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u53ea\u8bfb\u67e5\u8be2\u4f7f\u7528&#064;Transactional(readOnly &#061; true)\u63d0\u5347\u6027\u80fd\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a04\u200c.\u4f20\u64ad\u884c\u4e3a\u8c28\u614e\u9009\u62e9\u200c&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u591a\u6570\u636e\u66f4\u65b0\u7528REQUIRED&#xff0c;\u72ec\u7acb\u65e5\u5fd7\u8bb0\u5f55\u7528REQUIRES_NEW\u3002<\/p>\n<hr \/>\n<h3 style=\"background-color:transparent\">&#x1f4a5;\u7b2c\u56db\u7ae0&#xff1a; \u9ad8\u9636\u53cd\u6740\u6218\u672f\u5e93<\/h3>\n<h4>\u4e00\u3001IOC\u5bb9\u5668\u306e\u6b7b\u4ea1\u8ffd\u95ee<\/h4>\n<p>\u60c5\u666f\u6a21\u62df&#xff1a;\u5f53\u9762\u8bd5\u5b98\u8bf4&#034;BeanFactory\u548cApplicationContext\u533a\u522b\u8bb2\u4e00\u4e0b&#034;<\/p>\n<ul>\n<li>\n<p>&#x1f525; \u6807\u51c6\u7b54\u6848&#xff1a;\u57fa\u7840\u5a5a\u4ecb\u6240 vs \u8c6a\u534e\u5a5a\u604b\u4e2d\u5fc3&#xff08;\u652f\u6301\u56fd\u9645\u5a5a\u59fb\u3001\u5a5a\u524d\u57f9\u8bad\u7b49\u589e\u503c\u670d\u52a1&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u53cd\u6740\u8fde\u62db&#xff1a;<\/p>\n<\/li>\n<\/ul>\n<p>\/\/ \u8ffd\u95ee1&#xff1a;\u4e3a\u4ec0\u4e48ApplicationContext\u8981\u9884\u521d\u59cb\u5316Bean&#xff1f;<br \/>\n\/\/ \u7b54&#xff1a;\u5c31\u50cf\u5a5a\u4ecb\u6240\u63d0\u524d\u5ba1\u6838\u4f1a\u5458\u8d44\u6599&#xff08;\u52a0\u8f7d\u914d\u7f6e\u65f6\u521b\u5efa\u5bf9\u8c61&#xff09;&#xff0c;<br \/>\n\/\/    \u907f\u514d\u76f8\u4eb2\u73b0\u573a\u624d\u67e5\u6237\u53e3&#xff08;\u5ef6\u8fdf\u52a0\u8f7d\u5bfc\u81f4\u6027\u80fd\u6ce2\u52a8&#xff09; <\/p>\n<p>\/\/ \u8ffd\u95ee2&#xff1a;FactoryBean\u7684\u7279\u6b8a\u6027&#xff1f;<br \/>\n\/\/ \u7b54&#xff1a;\u8fd9\u4e0d\u662f\u666e\u901a\u7ea2\u5a18&#xff0c;\u662f\u7ea2\u5a18\u57f9\u8bad\u5e08&#xff08;\u80fd\u751f\u4ea7\u7279\u6b8a\u5bf9\u8c61&#xff09;&#xff0c;getObject()\u5c31\u662f\u6bd5\u4e1a\u5178\u793c <\/p>\n<h4>\u4e8c\u3001AOP\u306e\u9677\u9631\u62c6\u89e3<\/h4>\n<p>\u9ad8\u9891\u7ffb\u8f66\u9898&#xff1a;&#034;JDK\u52a8\u6001\u4ee3\u7406\u548cCGLIB\u5982\u4f55\u9009\u62e9&#xff1f;&#034;<\/p>\n<ul>\n<li>\n<p>&#x1f3ad; \u8868\u6f14\u5b66\u6d3e\u89e3\u91ca&#xff1a;<\/p>\n<\/li>\n<li>\n<p>JDK\u4ee3\u7406&#xff1a;\u8981\u6c42\u6f14\u5458\u5fc5\u987b\u6709\u7ecf\u7eaa\u516c\u53f8&#xff08;\u63a5\u53e3&#xff09;<\/p>\n<\/li>\n<li>\n<p>CGLIB&#xff1a;\u7d20\u4eba\u51fa\u9053\u4e5f\u80fd\u6367\u7ea2&#xff08;\u76f4\u63a5\u7ee7\u627f\u76ee\u6807\u7c7b&#xff09;<\/p>\n<\/li>\n<li>\n<p>&#x1f4a3; \u9690\u85cf\u8003\u70b9&#xff1a;<\/p>\n<\/li>\n<\/ul>\n<p># \u9677\u9631&#xff1a;final\u7c7b\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u7528CGLIB&#xff1f;<br \/>\n# \u7b54&#xff1a;\u5c31\u50cf\u7ed9\u5df2\u7edd\u80b2\u7684\u732b\u914d\u79cd&#xff08;\u65e0\u6cd5\u751f\u6210\u5b50\u7c7b&#xff09;&#xff0c;\u5efa\u8bae\u6539\u7528JDK\u4ee3\u7406\u6216\u91cd\u7ec4\u57fa\u56e0&#xff08;\u91cd\u6784\u4ee3\u7801&#xff09; <\/p>\n<h4>\u4e09\u3001\u4e8b\u52a1\u306e\u7edd\u5730\u53cd\u51fb<\/h4>\n<p>\u6b7b\u4ea1\u573a\u666f&#xff1a;&#034;&#064;Transactional\u5931\u6548\u7684N\u79cd\u59ff\u52bf&#034;<\/p>\n<ul>\n<li>\n<p>\u7ffb\u8f66\u5927\u5168&#xff1a;\u00a0<\/p>\n<\/li>\n<\/ul>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" style=\"width:500px\">\n<tbody>\n<tr>\n<td style=\"text-align:center\">\u4f5c\u6b7b\u884c\u4e3a\u00a0<\/td>\n<td style=\"text-align:center\">\u79d1\u5b66\u89e3\u91ca <\/td>\n<td style=\"text-align:center\">\u62a2\u6551\u65b9\u6848<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">\u81ea\u8c03\u7528<\/td>\n<td style=\"text-align:center\">\u81ea\u5bb6AA\u5236\u4e0d\u7b97\u6570&#xff08;\u975e\u4ee3\u7406\u8c03\u7528&#xff09;<\/td>\n<td style=\"text-align:center\">\u62c6\u5bb6\u5206\u7076&#xff08;\u62c6\u5206\u7c7b&#xff09;<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">\u5f02\u5e38\u7c7b\u578b\u4e0d\u5339\u914d<\/td>\n<td style=\"text-align:center\">\u53ea\u8ba4\u53d1\u7968\u4e0d\u8ba4\u6536\u636e<\/td>\n<td style=\"text-align:center\">&#064;Transactional(rollbackFor&#061;Exception.class)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align:center\">\u975epublic\u65b9\u6cd5<\/td>\n<td style=\"text-align:center\">\u79c1\u623f\u94b1\u4e0d\u53c2\u4e0e\u5bb6\u5ead\u8bb0\u8d26<\/td>\n<td style=\"text-align:center\">\u6539\u7528AspectJ\u6a21\u5f0f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u7ec8\u6781\u5927\u6740\u5668&#xff1a;\u6e90\u7801\u7ea7\u53cd\u95ee<\/h4>\n<p>\u5f53\u9762\u8bd5\u5b98\u9732\u51fa\u6ee1\u610f\u8868\u60c5\u65f6&#xff0c;\u7a81\u7136\u629b\u51fa&#xff1a;<\/p>\n<li>\n<p>&#034;Spring\u5982\u4f55\u89e3\u51b3\u5faa\u73af\u4f9d\u8d56\u7684\u4e09\u7ea7\u7f13\u5b58&#xff1f;&#034;<\/p>\n<p> \u53c2\u8003\u7b54\u6848&#xff1a;\u5c31\u50cf\u5a5a\u4ecb\u6240\u8c03\u89e3\u4e09\u89d2\u604b&#xff0c;\u4e00\u7ea7\u7f13\u5b58&#xff08;\u7ed3\u5a5a\u8bc1&#xff09;\u3001\u4e8c\u7ea7\u7f13\u5b58&#xff08;\u8ba2\u5a5a\u534f\u8bae&#xff09;\u3001\u4e09\u7ea7\u7f13\u5b58&#xff08;\u76f8\u4eb2\u8d44\u6599&#xff09;<\/li>\n<li>\n<p>&#034;AOP\u7684Advice\u6267\u884c\u987a\u5e8f\u5982\u4f55\u63a7\u5236&#xff1f;&#034;<\/p>\n<p> \u795e\u56de\u590d&#xff1a;\u5bfc\u6f14\u558a\u5361\u7684\u4f18\u5148\u7ea7&#xff0c;&#064;Order(1)\u6bd4&#064;Order(2)\u5148\u558acut<\/li>\n<hr \/>\n<h3>&#x1f381;\u7b2c\u516d\u7ae0\u3001\u5f69\u86cb<\/h3>\n<h4>\u5f69\u86cb\u5347\u7ea7&#xff1a;Spring\u9762\u8bd5\u907f\u5751\u6307\u5357<\/h4>\n<table>\n<tbody>\n<tr>\n<p style=\"text-align:center\">\u9677\u9631\u7c7b\u578b<\/p>\n<p style=\"text-align:center\">\u5178\u578b\u6848\u4f8b<\/p>\n<p style=\"text-align:center\">\u89e3\u51b3\u65b9\u6848<\/p>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u914d\u7f6e\u9677\u9631<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">&#064;Transactional\u672a\u751f\u6548<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u68c0\u67e5\u4ee3\u7406\u6a21\u5f0f\u4e0e\u5f02\u5e38\u7c7b\u578b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u6027\u80fd\u9677\u9631<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u8fc7\u5ea6AOP\u5bfc\u81f4\u94fe\u8def\u53d8\u957f<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u4f7f\u7528\u6761\u4ef6\u5207\u9762(&#064;Conditional)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u5e76\u53d1\u9677\u9631<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u5355\u4f8bBean\u4e2d\u7684\u6210\u5458\u53d8\u91cf<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u6539\u7528ThreadLocal\u5b58\u50a8<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u6d4b\u8bd5\u9677\u9631<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u5355\u5143\u6d4b\u8bd5\u6c61\u67d3Spring\u4e0a\u4e0b\u6587<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u4f7f\u7528&#064;MockBean\u9694\u79bb\u4f9d\u8d56<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"background-color:transparent\">Spring\u9762\u8bd5\u901f\u67e5\u8868<\/h4>\n<table>\n<tbody>\n<tr>\n<p style=\"text-align:center\">\u6982\u5ff5<\/p>\n<p style=\"text-align:center\">\u8bb0\u5fc6\u53e3\u8bc0<\/p>\n<p style=\"text-align:center\">\u5178\u578b\u95ee\u9898<\/p>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">IOC<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">&#034;\u4e0d\u7528new&#xff0c;\u7b49\u6ce8\u5165&#034;<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">Bean\u751f\u547d\u5468\u671f\/\u5faa\u73af\u4f9d\u8d56<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">AOP<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">&#034;\u52a8\u6001\u4ee3\u7406&#043;\u5207\u9762&#061;\u89e3\u8026&#034;<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u901a\u77e5\u7c7b\u578b\/\u52a8\u6001\u4ee3\u7406\u533a\u522b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u4e8b\u52a1<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">&#034;ACID&#043;\u4f20\u64ad&#043;\u9694\u79bb&#061;\u5b89\u5168&#034;<\/p>\n<\/td>\n<td colspan=\"1\" rowspan=\"1\">\n<p style=\"text-align:center\">\u4f20\u64ad\u884c\u4e3a\/\u5931\u6548\u573a\u666f<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"background-color:transparent\">\u8c03\u8bd5\u4e0d\u662f\u5931\u8d25&#xff0c;\u800c\u662f\u6210\u957f\u7684\u5fc5\u7ecf\u4e4b\u8def\u3002\u6bcf\u4e00\u6b21\u89e3\u51b3bug&#xff0c;\u90fd\u662f\u5728\u79ef\u7d2f\u7ecf\u9a8c\u3002<\/h4>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"494\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811032408-689962580a8bd.png\" width=\"370\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb514\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf2\u6b21\u3002Spring\u9762\u8bd5\u6df1\u5ea6\u89e3\u6790\uff1aIOC\u3001AOP\u4e0e\u4e8b\u52a1\u7ba1\u7406\u6838\u5fc3\u8981\u70b9 \u6458\u8981\uff1a\u672c\u6587\u7cfb\u7edf\u89e3\u6790Spring\u6846\u67b6\u4e09\u5927\u6838\u5fc3\u6a21\u5757\u7684\u9762\u8bd5\u91cd\u70b9\u3002IOC\u5bb9\u5668\u901a\u8fc7\u63a7\u5236\u53cd\u8f6c\u5b9e\u73b0\u89e3\u8026\uff0c\u91c7\u7528\u4e09\u7ea7\u7f13\u5b58\u89e3\u51b3\u5faa\u73af\u4f9d\u8d56\uff0c\u5bf9\u6bd4\u5de5\u5382\u6a21\u5f0f\u51f8\u663e\u81ea\u52a8\u5316\u7ba1\u7406\u4f18\u52bf\u3002AOP\u63d0\u4f9b\u4e94\u79cd\u901a\u77e5\u7c7b\u578b\uff0c\u57fa\u4e8e\u52a8\u6001\u4ee3\u7406\u5b9e\u73b0\u975e\u4fb5\u5165\u5f0f\u589e\u5f3a\uff0c\u9700\u6ce8\u610f\u5207\u5165\u70b9\u8868\u8fbe\u5f0f\u4f18\u5316\u4e0e\u4ee3\u7406\u673a\u5236\u9009\u62e9\u3002\u4e8b\u52a1\u7ba1\u7406\u6db5\u76d6ACID\u7279\u6027\u4e0e\u4e03\u79cd\u4f20\u64ad\u884c\u4e3a\uff0c\u5256\u6790@Transactional\u5931\u6548\u7684\u5e38\u89c1\u573a\u666f\u53ca\u89e3\u51b3\u65b9\u6848\u3002\u6587\u7ae0\u901a\u8fc7\u5a5a\u4ecb\u6240\u3001\u7535\u5f71\u62cd\u6444\u7b49\u751f\u52a8\u7c7b\u6bd4\uff0c\u7ed3\u5408\u6e90\u7801\u7ea7\u5206\u6790\uff08\u5982BeanDefinition\u89e3\u6790\u3001\u4e8b\u52a1\u72b6\u6001\u673a\u7b49\uff09\uff0c\u63d0\u4f9b\u4ece\u57fa\u7840<\/p>\n","protected":false},"author":2,"featured_media":52192,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4887,5220,101,5221,176],"topic":[],"class_list":["post-52196","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-aop","tag-ioc","tag-spring","tag-5221","tag-176"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring\u9762\u8bd5\u53cd\u6740\u6307\u5357\uff1a\u628aIOC\u5f53\u5a5a\u4ecb\u6240\uff0cAOP\u5f53\u5bfc\u6f14\uff0c\u4e8b\u52a1\u5f53AA\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/52196.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring\u9762\u8bd5\u53cd\u6740\u6307\u5357\uff1a\u628aIOC\u5f53\u5a5a\u4ecb\u6240\uff0cAOP\u5f53\u5bfc\u6f14\uff0c\u4e8b\u52a1\u5f53AA\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb514\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf2\u6b21\u3002Spring\u9762\u8bd5\u6df1\u5ea6\u89e3\u6790\uff1aIOC\u3001AOP\u4e0e\u4e8b\u52a1\u7ba1\u7406\u6838\u5fc3\u8981\u70b9 \u6458\u8981\uff1a\u672c\u6587\u7cfb\u7edf\u89e3\u6790Spring\u6846\u67b6\u4e09\u5927\u6838\u5fc3\u6a21\u5757\u7684\u9762\u8bd5\u91cd\u70b9\u3002IOC\u5bb9\u5668\u901a\u8fc7\u63a7\u5236\u53cd\u8f6c\u5b9e\u73b0\u89e3\u8026\uff0c\u91c7\u7528\u4e09\u7ea7\u7f13\u5b58\u89e3\u51b3\u5faa\u73af\u4f9d\u8d56\uff0c\u5bf9\u6bd4\u5de5\u5382\u6a21\u5f0f\u51f8\u663e\u81ea\u52a8\u5316\u7ba1\u7406\u4f18\u52bf\u3002AOP\u63d0\u4f9b\u4e94\u79cd\u901a\u77e5\u7c7b\u578b\uff0c\u57fa\u4e8e\u52a8\u6001\u4ee3\u7406\u5b9e\u73b0\u975e\u4fb5\u5165\u5f0f\u589e\u5f3a\uff0c\u9700\u6ce8\u610f\u5207\u5165\u70b9\u8868\u8fbe\u5f0f\u4f18\u5316\u4e0e\u4ee3\u7406\u673a\u5236\u9009\u62e9\u3002\u4e8b\u52a1\u7ba1\u7406\u6db5\u76d6ACID\u7279\u6027\u4e0e\u4e03\u79cd\u4f20\u64ad\u884c\u4e3a\uff0c\u5256\u6790@Transactional\u5931\u6548\u7684\u5e38\u89c1\u573a\u666f\u53ca\u89e3\u51b3\u65b9\u6848\u3002\u6587\u7ae0\u901a\u8fc7\u5a5a\u4ecb\u6240\u3001\u7535\u5f71\u62cd\u6444\u7b49\u751f\u52a8\u7c7b\u6bd4\uff0c\u7ed3\u5408\u6e90\u7801\u7ea7\u5206\u6790\uff08\u5982BeanDefinition\u89e3\u6790\u3001\u4e8b\u52a1\u72b6\u6001\u673a\u7b49\uff09\uff0c\u63d0\u4f9b\u4ece\u57fa\u7840\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/52196.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-11T03:24:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811032407-689962570590d.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/52196.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/52196.html\",\"name\":\"Spring\u9762\u8bd5\u53cd\u6740\u6307\u5357\uff1a\u628aIOC\u5f53\u5a5a\u4ecb\u6240\uff0cAOP\u5f53\u5bfc\u6f14\uff0c\u4e8b\u52a1\u5f53AA\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-11T03:24:09+00:00\",\"dateModified\":\"2025-08-11T03:24:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/52196.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/52196.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/52196.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring\u9762\u8bd5\u53cd\u6740\u6307\u5357\uff1a\u628aIOC\u5f53\u5a5a\u4ecb\u6240\uff0cAOP\u5f53\u5bfc\u6f14\uff0c\u4e8b\u52a1\u5f53AA\u5236\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring\u9762\u8bd5\u53cd\u6740\u6307\u5357\uff1a\u628aIOC\u5f53\u5a5a\u4ecb\u6240\uff0cAOP\u5f53\u5bfc\u6f14\uff0c\u4e8b\u52a1\u5f53AA\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/52196.html","og_locale":"zh_CN","og_type":"article","og_title":"Spring\u9762\u8bd5\u53cd\u6740\u6307\u5357\uff1a\u628aIOC\u5f53\u5a5a\u4ecb\u6240\uff0cAOP\u5f53\u5bfc\u6f14\uff0c\u4e8b\u52a1\u5f53AA\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb514\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf2\u6b21\u3002Spring\u9762\u8bd5\u6df1\u5ea6\u89e3\u6790\uff1aIOC\u3001AOP\u4e0e\u4e8b\u52a1\u7ba1\u7406\u6838\u5fc3\u8981\u70b9 \u6458\u8981\uff1a\u672c\u6587\u7cfb\u7edf\u89e3\u6790Spring\u6846\u67b6\u4e09\u5927\u6838\u5fc3\u6a21\u5757\u7684\u9762\u8bd5\u91cd\u70b9\u3002IOC\u5bb9\u5668\u901a\u8fc7\u63a7\u5236\u53cd\u8f6c\u5b9e\u73b0\u89e3\u8026\uff0c\u91c7\u7528\u4e09\u7ea7\u7f13\u5b58\u89e3\u51b3\u5faa\u73af\u4f9d\u8d56\uff0c\u5bf9\u6bd4\u5de5\u5382\u6a21\u5f0f\u51f8\u663e\u81ea\u52a8\u5316\u7ba1\u7406\u4f18\u52bf\u3002AOP\u63d0\u4f9b\u4e94\u79cd\u901a\u77e5\u7c7b\u578b\uff0c\u57fa\u4e8e\u52a8\u6001\u4ee3\u7406\u5b9e\u73b0\u975e\u4fb5\u5165\u5f0f\u589e\u5f3a\uff0c\u9700\u6ce8\u610f\u5207\u5165\u70b9\u8868\u8fbe\u5f0f\u4f18\u5316\u4e0e\u4ee3\u7406\u673a\u5236\u9009\u62e9\u3002\u4e8b\u52a1\u7ba1\u7406\u6db5\u76d6ACID\u7279\u6027\u4e0e\u4e03\u79cd\u4f20\u64ad\u884c\u4e3a\uff0c\u5256\u6790@Transactional\u5931\u6548\u7684\u5e38\u89c1\u573a\u666f\u53ca\u89e3\u51b3\u65b9\u6848\u3002\u6587\u7ae0\u901a\u8fc7\u5a5a\u4ecb\u6240\u3001\u7535\u5f71\u62cd\u6444\u7b49\u751f\u52a8\u7c7b\u6bd4\uff0c\u7ed3\u5408\u6e90\u7801\u7ea7\u5206\u6790\uff08\u5982BeanDefinition\u89e3\u6790\u3001\u4e8b\u52a1\u72b6\u6001\u673a\u7b49\uff09\uff0c\u63d0\u4f9b\u4ece\u57fa\u7840","og_url":"https:\/\/www.wsisp.com\/helps\/52196.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-11T03:24:09+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811032407-689962570590d.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/52196.html","url":"https:\/\/www.wsisp.com\/helps\/52196.html","name":"Spring\u9762\u8bd5\u53cd\u6740\u6307\u5357\uff1a\u628aIOC\u5f53\u5a5a\u4ecb\u6240\uff0cAOP\u5f53\u5bfc\u6f14\uff0c\u4e8b\u52a1\u5f53AA\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-11T03:24:09+00:00","dateModified":"2025-08-11T03:24:09+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/52196.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/52196.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/52196.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Spring\u9762\u8bd5\u53cd\u6740\u6307\u5357\uff1a\u628aIOC\u5f53\u5a5a\u4ecb\u6240\uff0cAOP\u5f53\u5bfc\u6f14\uff0c\u4e8b\u52a1\u5f53AA\u5236"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/52196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=52196"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/52196\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/52192"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=52196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=52196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=52196"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=52196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}