{"id":123289,"date":"2026-11-07T00:24:48","date_gmt":"2026-11-06T16:24:48","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/123289.html"},"modified":"2026-11-07T00:24:48","modified_gmt":"2026-11-06T16:24:48","slug":"leetcode100java%e9%9d%a2%e7%bb%8fddd%e9%a2%86%e5%9f%9f%e9%a9%b1%e5%8a%a8%e8%ae%be%e8%ae%a1%e7%90%86%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/123289.html","title":{"rendered":"LeetCode100+java\u9762\u7ecf+DDD\u9886\u57df\u9a71\u52a8\u8bbe\u8ba1\u7406\u89e3"},"content":{"rendered":"<p>        \/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/<br \/>\n        #content_views .toc,<br \/>\n        \/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/<br \/>\n        #content_views.markdown_views &gt; p:empty:has(+ .toc),<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty,<br \/>\n        \/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/<br \/>\n        #content_views.htmledit_views #main-toc,<br \/>\n        #content_views.htmledit_views #hr-toc,<br \/>\n        #content_views.htmledit_views p[id*=\\&#8221;-toc\\&#8221;] {<br \/>\n          display: none !important;<br \/>\n        }<br \/>\n        \/* \u76ee\u5f55\u53bb\u6389\u540e\uff0c\u7d27\u8ddf\u7684\u9996\u4e2a\u6807\u9898\u4e0d\u518d\u591a\u51fa\u4e00\u5757\u4e0a\u8fb9\u8ddd *\/<br \/>\n        #content_views.markdown_views &gt; .toc + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + h4,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h4 {<br \/>\n          margin-top: 0 !important;<br \/>\n        }<\/p>\n<p>\u601d\u8003&#xff1a;\u5b66\u4e60\u6d4b\u5f00\u77e5\u8bc6\u5e76\u642d\u4e00\u4e2a\u9879\u76ee&#xff0c;\u540e\u7eed\u5168\u6808&#xff0c;agent&#xff0c;\u6d4b\u5f00\u90fd\u80fd\u6295<\/p>\n<p>\u76db\u6700\u591a\u6c34\u7684\u5bb9\u5668<\/p>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u957f\u5ea6\u4e3a n \u7684\u6574\u6570\u6570\u7ec4\u00a0height\u00a0\u3002\u6709\u00a0n\u00a0\u6761\u5782\u7ebf&#xff0c;\u7b2c i \u6761\u7ebf\u7684\u4e24\u4e2a\u7aef\u70b9\u662f\u00a0(i, 0)\u00a0\u548c\u00a0(i, height[i])\u00a0\u3002<\/p>\n<p>\u627e\u51fa\u5176\u4e2d\u7684\u4e24\u6761\u7ebf&#xff0c;\u4f7f\u5f97\u5b83\u4eec\u4e0e\u00a0x\u00a0\u8f74\u5171\u540c\u6784\u6210\u7684\u5bb9\u5668\u53ef\u4ee5\u5bb9\u7eb3\u6700\u591a\u7684\u6c34\u3002<\/p>\n<p>\u8fd4\u56de\u5bb9\u5668\u53ef\u4ee5\u50a8\u5b58\u7684\u6700\u5927\u6c34\u91cf\u3002<\/p>\n<p>\u601d\u8def&#xff1a;\u53cc\u6307\u9488\u5f80\u4e2d\u95f4\u8d70&#xff0c;\u6bcf\u6b21\u8ba1\u7b97\u5f53\u524d\u5bb9\u79ef&#xff0c;\u8981\u6c42\u6700\u5927\u6c34\u5bb9\u91cf&#xff0c;\u5de6\u53f3\u54ea\u8fb9\u5c0f\u79fb\u52a8\u54ea\u8fb9<br \/>\nclass Solution {<\/p>\n<p>public int maxArea(int[] height) {<\/p>\n<p>int left&#061;0;<\/p>\n<p>int right&#061;height.length-1;<\/p>\n<p>int max&#061;0;<\/p>\n<p>while(left&lt;right){<\/p>\n<p>int cur&#061;-1;<\/p>\n<p>if(height[left]&lt;height[right]){<\/p>\n<p>cur&#061;height[left]*(right-left);<\/p>\n<p>left&#043;&#043;;<\/p>\n<p>}<\/p>\n<p>else{<\/p>\n<p>cur&#061;height[right]*(right-left);<\/p>\n<p>right\u2013;<\/p>\n<p>}<\/p>\n<p>if(cur&gt;max)max&#061;cur;<\/p>\n<p>}<\/p>\n<p>return max;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>\u4e24\u6570\u4e4b\u548c<\/p>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u6574\u6570\u6570\u7ec4 nums\u00a0\u548c\u4e00\u4e2a\u6574\u6570\u76ee\u6807\u503c target&#xff0c;\u8bf7\u4f60\u5728\u8be5\u6570\u7ec4\u4e2d\u627e\u51fa \u548c\u4e3a\u76ee\u6807\u503c target\u00a0 \u7684\u90a3\u00a0\u4e24\u4e2a\u00a0\u6574\u6570&#xff0c;\u5e76\u8fd4\u56de\u5b83\u4eec\u7684\u6570\u7ec4\u4e0b\u6807\u3002<\/p>\n<p>\u601d\u8def&#xff1a;Hashmap<br \/>\n\u6613\u9519&#xff1a;\u4e0d\u80fd\u4e00\u5f00\u59cb\u5c31\u5efa\u7acb\u6570\u5b57-&gt;\u7d22\u5f15&#xff0c;\u5f53target&#061;2*nums[i]\u4f1a\u51fa\u91cd\u590d<br \/>\nclass Solution {<\/p>\n<p>public int[] twoSum(int[] nums, int target) {<\/p>\n<p>Map&lt;Integer,Integer&gt; map&#061;new HashMap&lt;&gt;();<\/p>\n<p>for(int i&#061;0;i&lt;nums.length;i&#043;&#043;){<\/p>\n<p>if(map.containsKey(target-nums[i])){<\/p>\n<p>return new int[]{i,map.get(target-nums[i])};<\/p>\n<p>}<\/p>\n<p>map.put(nums[i],i);<\/p>\n<p>}<\/p>\n<p>return null;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>5.Java\u8bbe\u8ba1\u6a21\u5f0f&#xff1a;\u8bb2\u4e00\u4e0b\u7b56\u7565\u6a21\u5f0f\u3002<br \/>\n\u662f\u4e00\u79cd\u4ee3\u7801\u8bbe\u8ba1\u6a21\u5f0f&#xff0c;\u4e3b\u8981\u76ee\u7684\u5c31\u662f\u4e3a\u4e86\u6d88\u9664\u5927\u91cf\u7684ifelse\u4ee3\u7801&#xff0c;\u6bd4\u5982\u4e00\u4e2a\u652f\u4ed8\u529f\u80fd&#xff0c;\u652f\u6301\u5fae\u4fe1\u652f\u4ed8\u5b9d\u7b49&#xff0c;\u6700\u7b80\u5355\u5199\u6cd5\u662f\u5229\u7528ifelse\u6839\u636e\u652f\u4ed8\u7c7b\u578b\u8d70\u5bf9\u5e94\u652f\u4ed8\u903b\u8f91&#xff0c;\u4f46\u5229\u7528\u7b56\u7565\u6a21\u5f0f&#xff0c;\u53ef\u4ee5\u5148\u5b9a\u4e49\u4e00\u4e2a\u652f\u4ed8\u63a5\u53e3&#xff0c;\u5bf9\u4e8e\u4e0d\u540c\u7684\u652f\u4ed8\u884c\u4e3a\u5b9e\u73b0\u4e0d\u540c\u7684\u652f\u4ed8\u7c7b&#xff0c;\u7136\u540e\u642d\u914d\u5de5\u5382\u6a21\u5f0f\u5199\u4e00\u4e2amap\u8fdb\u884c\u52a8\u6001\u7684\u652f\u4ed8\u7b56\u7565\u7684\u8def\u7531&#xff0c;\u5728\u8c03\u7528\u7684\u65f6\u5019\u4e1a\u52a1\u4ee3\u7801\u5c31\u53d8\u5f97\u5f88\u5e72\u51c0<br \/>\n\u597d\u5904&#xff1a;<\/p>\n<li>\n<p>\u6d88\u706d\u4e86 if-else&#xff1a;\u4f60\u7684\u4e3b\u6d41\u7a0b\u4ee3\u7801\u53d8\u5f97\u975e\u5e38\u5e72\u51c0\u3001\u6e05\u6670\u3002<\/p>\n<\/li>\n<li>\n<p>\u7b26\u5408\u201c\u5f00\u95ed\u539f\u5219\u201d&#xff1a;\u4e0b\u6b21\u52a0\u4e2a\u201c\u94f6\u8054\u652f\u4ed8\u201d\u3002\u4f60\u4e0d\u9700\u8981\u6539\u52a8\u4efb\u4f55\u73b0\u6709\u7684\u4ee3\u7801\u3002\u4f60\u53ea\u9700\u8981\u65b0\u5efa\u4e00\u4e2a UnionPayStrategy implements PayStrategy \u7c7b&#xff0c;\u6253\u4e0a &#064;Service(&#034;UNION&#034;) \u6ce8\u89e3&#xff0c;Spring \u81ea\u52a8\u5c31\u628a\u5b83\u6ce8\u518c\u8fdb\u53bb\u4e86\u3002\u4e1a\u52a1\u7acb\u9a6c\u5c31\u80fd\u7528&#xff01;<\/p>\n<\/li>\n<li>\n<p>\u804c\u8d23\u5355\u4e00&#xff1a;\u5fae\u4fe1\u652f\u4ed8\u51fa Bug \u4e86&#xff0c;\u4f60\u53ea\u9700\u8981\u53bb WechatPayStrategy \u91cc\u627e&#xff0c;\u7edd\u5bf9\u4e0d\u4f1a\u78b0\u5230\u652f\u4ed8\u5b9d\u7684\u4ee3\u7801<\/p>\n<\/li>\n<p>6\u00a0.\u67b6\u6784\u8bbe\u8ba1&#xff1a;\u4e86\u89e3\u00a0DDD&#xff08;Domain-Driven Design \u9886\u57df\u9a71\u52a8\u8bbe\u8ba1&#xff09;\u5417&#xff1f;<\/p>\n<p>\u201cDDD \u5e76\u4e0d\u662f\u4e00\u5957\u6280\u672f\u6846\u67b6&#xff0c;\u800c\u662f\u4e00\u79cd\u5e94\u5bf9\u590d\u6742\u4e1a\u52a1\u67b6\u6784\u7684\u65b9\u6cd5\u8bba\u3002\u4f20\u7edf\u7684 MVC \u6a21\u5f0f\u628a\u6240\u6709\u7684\u903b\u8f91\u5806\u5728 Service \u91cc&#xff0c;\u5bb9\u6613\u4ea7\u751f\u2018\u4e0a\u5e1d\u7c7b\u2019\u3002<\/p>\n<p>\u5f15\u5165 DDD \u540e&#xff0c;\u6211\u4eec\u4f1a\u6839\u636e\u4e1a\u52a1\u8fb9\u754c\u5212\u5206\u51fa\u4e0d\u540c\u7684**\u2018\u9650\u754c\u4e0a\u4e0b\u6587\u2019&#xff08;\u5fae\u670d\u52a1&#xff09;\u3002\u5728\u4ee3\u7801\u5b9e\u73b0\u4e0a&#xff0c;\u6211\u4eec\u4f1a\u91c7\u7528\u56db\u5c42\u67b6\u6784&#xff0c;\u628a\u6838\u5fc3\u4e1a\u52a1\u903b\u8f91\u6c89\u6dc0\u5230\u2018\u9886\u57df\u5c42\u2019&#xff0c;\u901a\u8fc7\u2018\u805a\u5408\u6839\u2019\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027&#xff0c;\u901a\u8fc7\u2018\u9886\u57df\u4e8b\u4ef6\u2019**\u5b9e\u73b0\u670d\u52a1\u95f4\u7684\u89e3\u8026\u3002<\/p>\n<p>\u6211\u66fe\u7ecf\u5728\u4e00\u4e2a\u7535\u5546\u9879\u76ee\u4e2d\u5e94\u7528\u8fc7 DDD&#xff0c;\u628a\u539f\u672c\u63c9\u5728\u4e00\u8d77\u7684\u8ba2\u5355\u3001\u5e93\u5b58\u3001\u8425\u9500\u7cfb\u7edf\u62c6\u5206&#xff0c;\u7528\u4e8b\u4ef6\u9a71\u52a8\u4e32\u8054&#xff0c;\u5927\u5927\u964d\u4f4e\u4e86\u7cfb\u7edf\u7684\u8026\u5408\u5ea6&#xff0c;\u63d0\u5347\u4e86\u4ee3\u7801\u7684\u53ef\u7ef4\u62a4\u6027\u3002\u201d<\/p>\n<p>MVC\u548cDDD\u533a\u522b<\/p>\n<p>\u5728 MVC \u4e2d&#xff0c;\u6240\u6709\u7684\u4e1a\u52a1\u903b\u8f91&#xff08;\u8ba1\u7b97\u4ef7\u683c\u3001\u5224\u65ad\u5e93\u5b58\u3001\u6821\u9a8c\u72b6\u6001&#xff09;\u90fd\u88ab\u585e\u8fdb\u4e86 Service \u5c42&#xff0c;\u800c Entity&#xff08;\u6570\u636e\u5e93\u5b9e\u4f53&#xff09;\u91cc\u53ea\u6709 getter \u548c setter\u3002<\/p>\n<p>\u5047\u8bbe\u4e1a\u52a1\u89c4\u5219\u662f&#xff1a;\u4e0b\u5355\u65f6&#xff0c;\u5fc5\u987b\u6821\u9a8c\u5e93\u5b58\u662f\u5426\u5145\u8db3&#xff0c;\u5982\u679c\u5145\u8db3\u5219\u6263\u51cf&#xff1b;\u5982\u679c\u8ba2\u5355\u603b\u91d1\u989d\u8d85\u8fc7 500 \u5143&#xff0c;\u8fd8\u9700\u8981\u6253 9 \u6298\u3002<\/p>\n<h4>\u4e00\u3001 \u4f20\u7edf MVC \u5199\u6cd5&#xff08;\u8d2b\u8840\u6a21\u578b&#xff09;<\/h4>\n<p>\u5728 MVC \u67b6\u6784\u4e0b&#xff0c;\u6211\u4eec\u7684\u5b9e\u4f53\u7c7b&#xff08;Entity&#xff09;\u901a\u5e38\u53ea\u662f\u4e2a\u201c\u6570\u636e\u888b\u201d&#xff0c;\u6240\u6709\u7684\u903b\u8f91\u5168\u5728 Service \u91cc\u3002<\/p>\n<h5>1. Entity&#xff08;\u8d2b\u8840\u6a21\u578b&#xff09;<\/h5>\n<p>java<\/p>\n<p>public class Order {<br \/>\nprivate Long id;<br \/>\nprivate Double totalAmount;<br \/>\nprivate Integer status;<br \/>\n\/\/ \u53ea\u6709 getter \u548c setter<br \/>\npublic Double getTotalAmount() { return totalAmount; }<br \/>\npublic void setTotalAmount(Double totalAmount) { this.totalAmount &#061; totalAmount; }<br \/>\n\/\/ \u2026 \u5176\u4ed6 getter\/setter<br \/>\n}<br \/>\npublic class Product {<br \/>\nprivate Long id;<br \/>\nprivate Integer stock;<br \/>\n\/\/ \u53ea\u6709 getter \u548c setter<br \/>\npublic Integer getStock() { return stock; }<br \/>\npublic void setStock(Integer stock) { this.stock &#061; stock; }<br \/>\n}<\/p>\n<h5>2. Service&#xff08;\u4e0a\u5e1d\u7c7b&#xff09;<\/h5>\n<p>\u6240\u6709\u7684\u4e1a\u52a1\u903b\u8f91\u3001\u5224\u65ad\u3001\u7b97\u94b1\u90fd\u5728\u8fd9\u91cc&#xff0c;\u968f\u7740\u9700\u6c42\u589e\u52a0&#xff0c;\u8fd9\u4e2a\u7c7b\u4f1a\u53d8\u5f97\u65e0\u6bd4\u81c3\u80bf\u3002<\/p>\n<p>java<\/p>\n<p>&#064;Service<br \/>\npublic class OrderService {<\/p>\n<p>&#064;Autowired<br \/>\nprivate ProductMapper productMapper;<br \/>\n&#064;Autowired<br \/>\nprivate OrderMapper orderMapper;<br \/>\npublic void createOrder(Long productId, Integer quantity) {<br \/>\n    \/\/ 1. \u67e5\u6570\u636e\u5e93<br \/>\n    Product product &#061; productMapper.selectById(productId);<\/p>\n<p>    \/\/ 2. \u4e1a\u52a1\u5224\u65ad&#xff1a;\u6821\u9a8c\u5e93\u5b58<br \/>\n    if (product.getStock() &lt; quantity) {<br \/>\n        throw new RuntimeException(&#034;\u5e93\u5b58\u4e0d\u8db3&#034;);<br \/>\n    }<\/p>\n<p>    \/\/ 3. \u4e1a\u52a1\u903b\u8f91&#xff1a;\u6263\u51cf\u5e93\u5b58 (\u76f4\u63a5\u4fee\u6539\u5c5e\u6027)<br \/>\n    product.setStock(product.getStock() &#8211; quantity);<br \/>\n    productMapper.updateById(product);<\/p>\n<p>    \/\/ 4. \u4e1a\u52a1\u903b\u8f91&#xff1a;\u8ba1\u7b97\u91d1\u989d<br \/>\n    Double amount &#061; 100.0 * quantity;<br \/>\n    if (amount &gt; 500) {<br \/>\n        amount &#061; amount * 0.9; \/\/ \u6ee1500\u62539\u6298<br \/>\n    }<\/p>\n<p>    \/\/ 5. \u521b\u5efa\u8ba2\u5355<br \/>\n    Order order &#061; new Order();<br \/>\n    order.setTotalAmount(amount);<br \/>\n    order.setStatus(1);<br \/>\n    orderMapper.insert(order);<\/p>\n<p>    System.out.println(&#034;\u4e0b\u5355\u6210\u529f&#xff0c;\u91d1\u989d&#xff1a;&#034; &#043; amount);<br \/>\n}<\/p>\n<p>}<\/p>\n<p>\u75db\u70b9&#xff1a;\u672a\u6765\u5982\u679c\u4ea7\u54c1\u7ecf\u7406\u8bf4\u201cVIP\u7528\u6237\u79ef\u5206\u8d85\u8fc71000\u4e5f\u53ef\u4ee5\u6253\u6298\u201d&#xff0c;\u4f60\u5f97\u7ee7\u7eed\u5728\u8fd9\u4e2a createOrder \u91cc\u9762\u5199 if-else\u3002\u6570\u636e&#xff08;Entity&#xff09;\u548c\u64cd\u4f5c\u6570\u636e\u7684\u884c\u4e3a&#xff08;Service&#xff09;\u5206\u5bb6\u4e86&#xff0c;\u975e\u5e38\u5bb9\u6613\u6539\u51fa Bug\u3002<\/p>\n<hr \/>\n<h4>\u4e8c\u3001 DDD \u5199\u6cd5&#xff08;\u5145\u8840\u6a21\u578b&#xff09;<\/h4>\n<p>\u5728 DDD \u4e2d&#xff0c;\u6211\u4eec\u5f3a\u8c03**\u201c\u8c01\u7684\u6570\u636e&#xff0c;\u8c01\u81ea\u5df1\u7ba1\u201d**\u3002\u6211\u4eec\u628a\u8ba1\u7b97\u91d1\u989d\u3001\u6263\u51cf\u5e93\u5b58\u7684\u884c\u4e3a&#xff0c;\u76f4\u63a5\u642c\u5230\u5b9e\u4f53\u5185\u90e8\u53bb\u3002<\/p>\n<h5>1. Domain \u5c42&#xff08;\u5145\u8840\u6a21\u578b&#xff09;<\/h5>\n<p>\u5b9e\u4f53\u4e0d\u518d\u53ea\u662f\u6570\u636e\u888b&#xff0c;\u5b83\u6709\u4e86\u81ea\u5df1\u7684\u201c\u7075\u9b42\u201d&#xff08;\u884c\u4e3a&#xff09;\u3002<\/p>\n<p>java<\/p>\n<p>\/\/ \u5546\u54c1\u5b9e\u4f53&#xff1a;\u81ea\u5df1\u8d1f\u8d23\u6263\u5e93\u5b58<br \/>\npublic class Product {<br \/>\nprivate Long id;<br \/>\nprivate Integer stock;<br \/>\npublic Integer getStock() { return stock; }<br \/>\n\/\/ \u6838\u5fc3\u4e1a\u52a1\u903b\u8f91&#xff1a;\u6263\u51cf\u5e93\u5b58\u7531\u5546\u54c1\u81ea\u5df1\u8d1f\u8d23<br \/>\npublic void deductStock(int quantity) {<br \/>\nif (this.stock &lt; quantity) {<br \/>\nthrow new BusinessException(\u201c\u5546\u54c1\u5e93\u5b58\u4e0d\u8db3\u201d);<br \/>\n}<br \/>\nthis.stock -&#061; quantity;<br \/>\n}<br \/>\n}<br \/>\n\/\/ \u8ba2\u5355\u5b9e\u4f53&#xff1a;\u81ea\u5df1\u8d1f\u8d23\u7b97\u94b1<br \/>\npublic class Order {<br \/>\nprivate Long id;<br \/>\nprivate Double totalAmount;<br \/>\npublic Double getTotalAmount() { return totalAmount; }<br \/>\n\/\/ \u6838\u5fc3\u4e1a\u52a1\u903b\u8f91&#xff1a;\u8ba1\u7b97\u603b\u4ef7\u7531\u8ba2\u5355\u81ea\u5df1\u8d1f\u8d23<br \/>\npublic void calculateTotalAmount(Double unitPrice, int quantity) {<br \/>\ndouble amount &#061; unitPrice * quantity;<br \/>\nif (amount &gt; 500) {<br \/>\namount &#061; amount * 0.9;<br \/>\n}<br \/>\nthis.totalAmount &#061; amount;<br \/>\n}<br \/>\n}<\/p>\n<h5>2. Application \u5c42&#xff08;\u5e94\u7528\u670d\u52a1&#xff09;<\/h5>\n<p>\u5e94\u7528\u670d\u52a1\u53d8\u6210\u4e86\u201c\u5149\u6746\u53f8\u4ee4\u201d&#xff0c;\u5b83\u53ea\u8d1f\u8d23\u8c03\u5ea6&#xff1a;\u62ff\u6570\u636e -&gt; \u8c03\u9886\u57df\u6a21\u578b -&gt; \u5b58\u6570\u636e\u3002\u6ca1\u6709\u5177\u4f53\u7684\u4e1a\u52a1\u5224\u65ad\u3002<\/p>\n<p>java<\/p>\n<p>&#064;Service<br \/>\npublic class OrderApplicationService {<br \/>\n&#064;Autowired<br \/>\nprivate ProductRepository productRepository;<br \/>\n&#064;Autowired<br \/>\nprivate OrderRepository orderRepository;<br \/>\n&#064;Transactional<br \/>\npublic void createOrder(Long productId, Integer quantity) {<br \/>\n\/\/ 1. \u83b7\u53d6\u805a\u5408\u6839&#xff08;\u901a\u8fc7 Repository \u67e5\u51fa\u6765&#xff09;<br \/>\nProduct product &#061; productRepository.findById(productId);<\/p>\n<p>    \/\/ 2. \u59d4\u6258\u7ed9\u9886\u57df\u6a21\u578b\u81ea\u5df1\u53bb\u6263\u5e93\u5b58&#xff08;\u5b83\u5185\u90e8\u6709\u6821\u9a8c\u903b\u8f91&#xff09;<br \/>\n    product.deductStock(quantity);<\/p>\n<p>    \/\/ 3. \u521b\u5efa\u8ba2\u5355\u5e76\u59d4\u6258\u9886\u57df\u6a21\u578b\u81ea\u5df1\u7b97\u94b1<br \/>\n    Order order &#061; new Order();<br \/>\n    order.calculateTotalAmount(100.0, quantity);<\/p>\n<p>    \/\/ 4. \u6301\u4e45\u5316<br \/>\n    productRepository.save(product);<br \/>\n    orderRepository.save(order);<br \/>\n}<\/p>\n<p>}<\/p>\n<hr \/>\n<h4>\u4e09\u3001 \u7528\u4ee3\u7801\u770b\u672c\u8d28\u533a\u522b<\/h4>\n<p>\u5bf9\u6bd4\u4e00\u4e0b\u4e0a\u9762\u4e24\u6bb5\u4ee3\u7801&#xff1a;<\/p>\n<li>\n<p>\u5728 MVC \u4e2d&#xff1a;OrderService \u50cf\u4e2a\u64cd\u788e\u4e86\u5fc3\u7684\u8001\u6bcd\u4eb2&#xff0c;\u4e0d\u4f46\u8981\u67e5\u6570\u636e\u5e93&#xff0c;\u8fd8\u8981\u7ba1\u7b97\u8d26\u3001\u7ba1\u6263\u5e93\u5b58\u3002\u5982\u679c\u7b97\u8d26\u903b\u8f91\u51fa\u9519\u4e86&#xff0c;\u4f60\u9700\u8981\u5728\u4e00\u4e2a\u51e0\u5343\u884c\u7684 Service \u91cc\u627e\u534a\u5929\u3002<\/p>\n<\/li>\n<li>\n<p>\u5728 DDD \u4e2d&#xff1a;OrderApplicationService \u5c31\u50cf\u4e2a\u9879\u76ee\u7ecf\u7406&#xff0c;\u5b83\u53ea\u8bf4\u4e00\u53e5&#xff1a;order.calculateTotalAmount(&#8230;) \u548c product.deductStock(&#8230;)\u3002\u5177\u4f53\u600e\u4e48\u7b97\u3001\u600e\u4e48\u6263&#xff0c;\u8ba9 Order \u548c Product \u8fd9\u4e24\u4e2a\u201c\u4e13\u5bb6&#xff08;\u5b9e\u4f53&#xff09;\u201d\u81ea\u5df1\u53bb\u641e\u5b9a\u3002<\/p>\n<\/li>\n<p>\u201c\u8c08\u8c08\u4f60\u5bf9 DDD\u3001MVC \u548c\u5fae\u670d\u52a1\u7684\u7406\u89e3&#xff1f;\u201d<\/p>\n<p>\u201c\u6211\u8ba4\u4e3a\u8fd9\u4e09\u8005\u662f\u4e0d\u540c\u7ef4\u5ea6\u7684\u6982\u5ff5\u3002<\/p>\n<p>MVC \u662f\u4e00\u79cd\u6280\u672f\u5b9e\u73b0\u67b6\u6784&#xff0c;\u5b83\u901a\u8fc7 Controller\u3001Service\u3001DAO \u5b9e\u73b0\u4ee3\u7801\u5206\u5c42&#xff0c;\u4f46\u5728\u590d\u6742\u4e1a\u52a1\u4e2d&#xff0c;\u5bb9\u6613\u5bfc\u81f4 Service \u5c42\u53d8\u6210\u2018\u4e0a\u5e1d\u7c7b\u2019&#xff08;\u8d2b\u8840\u6a21\u578b&#xff09;\u3002<\/p>\n<p>DDD \u662f\u4e00\u79cd\u5e94\u5bf9\u590d\u6742\u4e1a\u52a1\u7684\u65b9\u6cd5\u8bba\u3002\u5b83\u7684\u6838\u5fc3\u662f\u628a\u4e1a\u52a1\u903b\u8f91\u6536\u62e2\u5230\u9886\u57df\u6a21\u578b\u4e2d&#xff08;\u5145\u8840\u6a21\u578b&#xff09;&#xff0c;\u5e76\u901a\u8fc7\u5212\u5206\u2018\u9650\u754c\u4e0a\u4e0b\u6587\u2019\u548c\u2018\u805a\u5408\u6839\u2019\u6765\u4fdd\u8bc1\u4e1a\u52a1\u7684\u9ad8\u5185\u805a\u3002<\/p>\n<p>\u5fae\u670d\u52a1 \u662f\u4e00\u79cd\u7269\u7406\u90e8\u7f72\u67b6\u6784\u3002&#xff0c;\u5982\u679c\u6ca1\u6709 DDD \u7684\u6307\u5bfc&#xff0c;\u5fae\u670d\u52a1\u5f88\u5bb9\u6613\u62c6\u6210\u2018\u5206\u5e03\u5f0f\u5355\u4f53\u2019\u3002<\/p>\n<p>\u6240\u4ee5&#xff0c;\u5b9e\u9645\u5de5\u7a0b\u4e2d&#xff0c;\u6211\u4eec\u901a\u5e38\u7528 DDD \u7684\u601d\u60f3\u6765\u5212\u5206\u5fae\u670d\u52a1\u7684\u8fb9\u754c&#xff0c;\u628a\u6bcf\u4e2a\u9650\u754c\u4e0a\u4e0b\u6587\u843d\u5730\u4e3a\u4e00\u4e2a\u5fae\u670d\u52a1&#xff0c;\u7136\u540e\u7528 MVC \u6216\u516d\u8fb9\u5f62\u67b6\u6784\u5728\u5fae\u670d\u52a1\u5185\u90e8\u5b9e\u73b0\u4ee3\u7801\u5206\u5c42\u3002\u8fd9\u6837\u65e2\u6709\u5b8f\u89c2\u7684\u4e1a\u52a1\u89e3\u8026&#xff0c;\u53c8\u6709\u5fae\u89c2\u7684\u6280\u672f\u5b9e\u73b0\u3002\u201d<\/p>\n<p>7.\u00a0Redis&#xff1a;Redis\u00a0\u4e3a\u4ec0\u4e48\u90a3\u4e48\u5feb&#xff1f;<\/p>\n<li>\n<p>\u7eaf\u5185\u5b58\u64cd\u4f5c&#xff1a;\u57fa\u4e8e\u5185\u5b58&#xff0c;\u8bfb\u5199\u901f\u5ea6\u6781\u5feb&#xff0c;\u907f\u514d\u4e86\u78c1\u76d8 I\/O\u3002<\/p>\n<\/li>\n<li>\n<p>\u5355\u7ebf\u7a0b\u6a21\u578b&#xff08;\u9488\u5bf9\u547d\u4ee4\u6267\u884c&#xff09;&#xff1a;\u907f\u514d\u4e86\u591a\u7ebf\u7a0b\u7684\u4e0a\u4e0b\u6587\u5207\u6362\u548c\u9501\u7ade\u4e89&#xff0c;\u4fdd\u8bc1\u4e86\u539f\u5b50\u6027&#xff08;6.0 \u4e4b\u540e\u7f51\u7edc I\/O \u662f\u591a\u7ebf\u7a0b&#xff0c;\u4f46\u6838\u5fc3\u547d\u4ee4\u6267\u884c\u4ecd\u662f\u5355\u7ebf\u7a0b&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>I\/O \u591a\u8def\u590d\u7528&#xff08;epoll&#xff09;&#xff1a;\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u4ee5\u540c\u65f6\u5904\u7406\u5927\u91cf\u7f51\u7edc\u8fde\u63a5&#xff0c;\u8ba9 CPU \u59cb\u7ec8\u5904\u4e8e\u9ad8\u5229\u7528\u7387\u3002<\/p>\n<\/li>\n<li>\n<p>\u9ad8\u6548\u7684\u6570\u636e\u7ed3\u6784&#xff1a;\u5982 SDS\u3001\u8df3\u8868&#xff08;ZSet&#xff09;\u3001\u54c8\u5e0c\u8868&#xff08;\u6e10\u8fdb\u5f0f rehash&#xff09;\u7b49&#xff0c;\u90fd\u7ecf\u8fc7\u6781\u81f4\u4f18\u5316\u3002<\/p>\n<\/li>\n<p>\u201c\u6bd4\u5982\u5728\u9ad8\u5e76\u53d1\u79d2\u6740\u573a\u666f\u4e0b&#xff0c;\u6bcf\u79d2\u51e0\u4e07\u6b21\u7684\u5e93\u5b58\u8bfb\u53d6\u548c\u6263\u51cf&#xff0c;\u4f20\u7edf\u6570\u636e\u5e93\u4f1a\u56e0\u4e3a\u884c\u9501\u548c\u78c1\u76d8 IO \u76f4\u63a5\u5d29\u6e83\u3002\u5229\u7528 Redis \u7684\u539f\u5b50\u547d\u4ee4&#xff08;\u5982 DECR&#xff09;\u5728\u5185\u5b58\u4e2d\u77ac\u95f4\u5b8c\u6210&#xff0c;\u6548\u7387\u6781\u9ad8\u3002\u201d<\/p>\n<p>8.\u00a0Spring&#xff1a;Spring\u00a0\u4e8b\u52a1\u5931\u6548\u7684\u573a\u666f\u6709\u54ea\u4e9b&#xff1f;<\/p>\n<p>\u201cSpring \u4e8b\u52a1\u5931\u6548\u7684\u672c\u8d28\u662f\u56e0\u4e3a AOP \u52a8\u6001\u4ee3\u7406\u6ca1\u6709\u751f\u6548\u3002\u5e38\u89c1\u573a\u666f\u6709 5 \u79cd&#xff1a;<\/p>\n<li>\n<p>\u65b9\u6cd5\u975e public&#xff1a;Spring \u4e8b\u52a1\u9ed8\u8ba4\u53ea\u80fd\u62e6\u622a public \u65b9\u6cd5\u3002<\/p>\n<\/li>\n<li>\n<p>\u81ea\u8c03\u7528&#xff1a;\u540c\u4e00\u4e2a\u7c7b\u4e2d&#xff0c;A \u65b9\u6cd5&#xff08;\u65e0\u4e8b\u52a1&#xff09;\u8c03\u7528 B \u65b9\u6cd5&#xff08;\u6709\u4e8b\u52a1&#xff09;&#xff0c;\u56e0\u4e3a\u8d70\u7684\u662f this \u5f15\u7528&#xff0c;\u4e0d\u7ecf\u8fc7\u4ee3\u7406\u7c7b\u3002<\/p>\n<\/li>\n<li>\n<p>\u5f02\u5e38\u88ab catch \u541e\u6389&#xff1a;\u6216\u8005\u629b\u51fa\u7684\u662f\u53d7\u68c0\u5f02\u5e38&#xff08;Checked Exception&#xff09;&#xff0c;\u9ed8\u8ba4\u4e0d\u56de\u6eda\u3002<\/p>\n<\/li>\n<li>\n<p>\u7c7b\u672a\u88ab Spring \u7ba1\u7406&#xff1a;\u6ca1\u6709\u52a0 &#064;Service \u7b49\u6ce8\u89e3\u3002<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u5e93\u5f15\u64ce\u4e0d\u652f\u6301&#xff1a;\u5982 MySQL \u7684 MyISAM\u3002\u201d<\/p>\n<\/li>\n<p>9.\u00a0Java\u5e76\u53d1&#xff1a;CAS\u00a0\u7684\u539f\u7406\u662f\u4ec0\u4e48&#xff1f;<\/p>\n<p>CAS&#xff08;Compare and Swap&#xff09;\u662f\u4e00\u79cd\u65e0\u9501\u5e76\u53d1\u673a\u5236&#xff0c;\u5305\u542b\u4e09\u4e2a\u64cd\u4f5c\u6570&#xff1a;\u5185\u5b58\u4f4d\u7f6e V\u3001\u9884\u671f\u539f\u503c A\u3001\u65b0\u503c B\u3002\u5f53\u4e14\u4ec5\u5f53 V \u7684\u503c\u7b49\u4e8e A \u65f6&#xff0c;\u624d\u4f1a\u5c06 V \u66f4\u65b0\u4e3a B&#xff0c;\u5426\u5219\u4e0d\u505a\u4efb\u4f55\u64cd\u4f5c&#xff0c;\u901a\u5e38\u914d\u5408\u81ea\u65cb\u5faa\u73af\u91cd\u8bd5\u3002<br \/>\n\u4f46\u5728\u9ad8\u5e76\u53d1\u4e0b&#xff0c;CAS \u6709\u4e09\u5927\u95ee\u9898&#xff1a;ABA \u95ee\u9898&#xff08;\u52a0\u7248\u672c\u53f7\u89e3\u51b3&#xff09;\u3001\u81ea\u65cb\u5f00\u9500\u5927\u3001\u53ea\u80fd\u4fdd\u8bc1\u4e00\u4e2a\u53d8\u91cf\u539f\u5b50\u6027\u3002<\/p>\n<p>10.\u00a0Java\u5e76\u53d1&#xff1a;synchronized\u00a0\u7684\u9501\u5347\u7ea7\u8fc7\u7a0b\u662f\u600e\u6837\u7684&#xff1f;<\/p>\n<p>\u201c\u4e3a\u4e86\u51cf\u5c11\u9501\u5e26\u6765\u7684\u6027\u80fd\u5f00\u9500&#xff0c;JDK 1.6 \u5f15\u5165\u4e86\u9501\u5347\u7ea7\u673a\u5236\u3002\u9501\u7684\u72b6\u6001\u4fdd\u5b58\u5728\u5bf9\u8c61\u5934\u7684 Mark Word \u4e2d&#xff0c;\u8fc7\u7a0b\u4e3a&#xff1a;<\/p>\n<li>\n<p>\u65e0\u9501&#xff1a;\u5bf9\u8c61\u521a\u521b\u5efa\u3002<\/p>\n<\/li>\n<li>\n<p>\u504f\u5411\u9501&#xff1a;\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u8bbf\u95ee\u65f6&#xff0c;\u76f4\u63a5\u5728\u5bf9\u8c61\u5934\u8bb0\u5f55\u7ebf\u7a0b ID&#xff0c;\u4e0b\u6b21\u8fdb\u6765\u76f4\u63a5\u653e\u884c&#xff0c;\u65e0\u9501\u5316\u5f00\u9500\u3002<\/p>\n<\/li>\n<li>\n<p>\u8f7b\u91cf\u7ea7\u9501&#xff1a;\u5f53\u6709\u591a\u4e2a\u7ebf\u7a0b\u4ea4\u66ff\u8bbf\u95ee\u65f6&#xff0c;\u504f\u5411\u9501\u5347\u7ea7\u4e3a\u8f7b\u91cf\u7ea7\u9501\u3002\u7ebf\u7a0b\u901a\u8fc7 CAS \u81ea\u65cb\u83b7\u53d6\u9501&#xff0c;\u4e0d\u4f1a\u963b\u585e\u3002<\/p>\n<\/li>\n<li>\n<p>\u91cd\u91cf\u7ea7\u9501&#xff1a;\u5982\u679c\u81ea\u65cb\u5931\u8d25&#xff08;\u5e76\u53d1\u51b2\u7a81\u4e25\u91cd&#xff09;&#xff0c;\u5347\u7ea7\u4e3a\u91cd\u91cf\u7ea7\u9501&#xff0c;\u6ca1\u62a2\u5230\u9501\u7684\u7ebf\u7a0b\u8fdb\u5165 Monitor \u7684 EntryList \u963b\u585e\u7b49\u5f85&#xff0c;\u7531\u64cd\u4f5c\u7cfb\u7edf\u5524\u9192\u3002\u201d<\/p>\n<\/li>\n<p>11.\u00a0\u573a\u666f\u9898&#xff1a;\u5982\u679c\u63a5\u624b\u4e86\u4e00\u5806\u00a0if-else\u00a0\u5d4c\u5957&#xff0c;\u91cc\u9762\u8fd8\u6709\u4e00\u5806\u00a0try-catch\u00a0\u7684\u4ee3\u7801&#xff0c;\u4f60\u4f1a\u600e\u4e48\u4f18\u5316\u91cd\u6784&#xff1f;<\/p>\n<p>\u4f7f\u7528\u8bbe\u8ba1\u6a21\u5f0f&#xff1a;\u5982\u679c if-else \u662f\u4e1a\u52a1\u7c7b\u578b\u5224\u65ad&#xff0c;\u5f15\u5165\u7b56\u7565\u6a21\u5f0f &#043; \u5de5\u5382\u6a21\u5f0f&#xff1b;\u5982\u679c\u662f\u72b6\u6001\u6d41\u8f6c&#xff0c;\u4f7f\u7528\u72b6\u6001\u6a21\u5f0f&#xff1b;\u5982\u679c\u662f\u53c2\u6570\u6821\u9a8c&#xff0c;\u4f7f\u7528\u8d23\u4efb\u94fe\u6a21\u5f0f\u3002<\/p>\n<table>\n<tr>\u6a21\u5f0f\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898\u6838\u5fc3\u7279\u5f81\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>\u7b56\u7565 &#043; \u5de5\u5382<\/td>\n<td>\u6d88\u9664\u5e73\u7ea7\u7684\u4e1a\u52a1\u7c7b\u578b\u5224\u65ad<\/td>\n<td>\u9009\u51fa\u552f\u4e00\u7684\u7b97\u6cd5\u53bb\u6267\u884c<\/td>\n<td>\u652f\u4ed8\u65b9\u5f0f\u3001\u767b\u5f55\u65b9\u5f0f\u3001\u6253\u6298\u8ba1\u7b97<\/td>\n<\/tr>\n<tr>\n<td>\u72b6\u6001\u6a21\u5f0f<\/td>\n<td>\u6d88\u9664\u968f\u72b6\u6001\u6539\u53d8\u7684\u5927\u91cf\u5206\u652f<\/td>\n<td>\u5185\u90e8\u72b6\u6001\u6539\u53d8\u5f15\u53d1\u884c\u4e3a\u6539\u53d8<\/td>\n<td>\u8ba2\u5355\u6d41\u8f6c\u3001\u7535\u68af\u8fd0\u884c\u3001\u7ea2\u7eff\u706f<\/td>\n<\/tr>\n<tr>\n<td>\u8d23\u4efb\u94fe\u6a21\u5f0f<\/td>\n<td>\u6d88\u9664\u4e32\u884c\u7684\u524d\u7f6e\u6821\u9a8c\u6216\u5ba1\u6279<\/td>\n<td>\u50cf\u94fe\u6761\u4e00\u6837\u4f9d\u6b21\u4f20\u9012\u5904\u7406<\/td>\n<td>\u53c2\u6570\u6821\u9a8c\u3001\u5ba1\u6279\u6d41\u3001\u62e6\u622a\u5668<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>12.\u00a0\u573a\u666f\u9898&#xff1a;\u5982\u679c\u6309\u7167\u4ea7\u54c1\u7ecf\u7406\u7684\u65b9\u6848\u505a\u51fa\u4e86\u6280\u672f\u65b9\u6848\u5e76\u4e0a\u7ebf&#xff0c;\u7ed3\u679c\u53d1\u73b0\u7cfb\u7edf\u51fa\u73b0\u4e86\u5f88\u4e25\u91cd\u7684\u95ee\u9898&#xff0c;\u8fd9\u4e2a\u65f6\u5019\u4f60\u8be5\u600e\u4e48\u89e3\u51b3&#xff1f;<\/p>\n<p>\u201c\u9047\u5230\u7ebf\u4e0a\u4e8b\u6545&#xff0c;\u7b2c\u4e00\u539f\u5219\u662f**\u300e\u5148\u6062\u590d&#xff0c;\u540e\u6392\u67e5&#xff0c;\u518d\u590d\u76d8\u300f**&#xff1a;<\/p>\n<li>\n<p>\u5feb\u901f\u6b62\u635f&#xff1a;\u7acb\u5373\u56de\u6eda\u6700\u8fd1\u7684\u4e0a\u7ebf\u7248\u672c&#xff08;\u524d\u63d0\u662f\u56de\u6eda\u5b89\u5168&#xff09;&#xff0c;\u6216\u8005\u901a\u8fc7\u914d\u7f6e\u4e2d\u5fc3\u964d\u7ea7\u8be5\u529f\u80fd\u5f00\u5173&#xff0c;\u4f18\u5148\u4fdd\u8bc1\u6838\u5fc3\u4e1a\u52a1\u53ef\u7528\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b9a\u4f4d\u95ee\u9898&#xff1a;\u67e5\u770b APM \u76d1\u63a7&#xff08;\u5982 SkyWalking&#xff09;\u3001\u65e5\u5fd7\u9519\u8bef\u7387\u3001\u6570\u636e\u5e93\u6162\u67e5\u8be2&#xff0c;\u6392\u67e5\u662f\u5426\u56e0\u4e3a\u6d41\u91cf\u7a81\u589e\u3001\u8d44\u6e90\u6b7b\u9501\u6216\u65b0\u4ee3\u7801\u7684 Bug\u3002<\/p>\n<\/li>\n<li>\n<p>\u9ad8\u6548\u4fee\u590d&#xff1a;\u5b9a\u4f4d\u5230 Bug \u540e&#xff0c;\u7d27\u6025\u62c9\u5206\u652f\u4fee\u590d&#xff0c;\u8d70\u7eff\u8272\u901a\u9053\u5feb\u901f\u6d4b\u8bd5\u4e0a\u7ebf\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e8b\u540e\u590d\u76d8&#xff1a;\u5199\u4e8b\u6545\u62a5\u544a&#xff08;RCA&#xff09;&#xff0c;\u5206\u6790\u6839\u56e0&#xff0c;\u5e76\u8865\u5145\u76d1\u63a7\u544a\u8b66\u3001\u5b8c\u5584\u6d4b\u8bd5\u7528\u4f8b&#xff08;\u7279\u522b\u662f\u6f0f\u6d4b\u7684\u8fb9\u754c\u573a\u666f&#xff09;&#xff0c;\u4f18\u5316\u53d1\u5e03\u6d41\u7a0b&#xff08;\u5f15\u5165\u7070\u5ea6\u53d1\u5e03&#xff09;\u3002\u201d<\/p>\n<\/li>\n<p>14.\u00a0\u7f13\u5b58\u8bbe\u8ba1&#xff1a;\u600e\u4e48\u4fdd\u8bc1\u00a0Redis\u00a0\u548c\u6570\u636e\u5e93\u7684\u6570\u636e\u4e00\u81f4\u6027&#xff1f;<\/p>\n<p>\u5199\u64cd\u4f5c&#xff1a;\u5148\u66f4\u65b0\u6570\u636e\u5e93&#xff0c;\u518d\u5220\u9664\u7f13\u5b58<br \/>\n\u8bfb\u64cd\u4f5c&#xff1a;\u5148\u8bfb\u7f13\u5b58&#xff0c;\u672a\u547d\u4e2d\u8bfb DB&#xff0c;\u7136\u540e\u56de\u5199\u7f13\u5b58\u3002<br \/>\n\u515c\u5e95\u65b9\u6848&#xff1a;\u9488\u5bf9\u9ad8\u4e00\u81f4\u6027\u4e1a\u52a1&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u76d1\u542c MySQL \u7684 Binlog&#xff08;\u5982 Canal&#xff09;&#xff0c;\u5c06\u53d8\u66f4\u5f02\u6b65\u540c\u6b65\u5230 Redis<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11820,99,2692,427],"topic":[],"class_list":["post-123289","post","type-post","status-publish","format-standard","hentry","category-server","tag-atomgit","tag-java","tag-leetcode","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>LeetCode100+java\u9762\u7ecf+DDD\u9886\u57df\u9a71\u52a8\u8bbe\u8ba1\u7406\u89e3 - \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\/123289.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LeetCode100+java\u9762\u7ecf+DDD\u9886\u57df\u9a71\u52a8\u8bbe\u8ba1\u7406\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/123289.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-06T16:24:48+00:00\" \/>\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=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123289.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/123289.html\",\"name\":\"LeetCode100+java\u9762\u7ecf+DDD\u9886\u57df\u9a71\u52a8\u8bbe\u8ba1\u7406\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-06T16:24:48+00:00\",\"dateModified\":\"2026-11-06T16:24:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/123289.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/123289.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/123289.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"LeetCode100+java\u9762\u7ecf+DDD\u9886\u57df\u9a71\u52a8\u8bbe\u8ba1\u7406\u89e3\"}]},{\"@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":"LeetCode100+java\u9762\u7ecf+DDD\u9886\u57df\u9a71\u52a8\u8bbe\u8ba1\u7406\u89e3 - \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\/123289.html","og_locale":"zh_CN","og_type":"article","og_title":"LeetCode100+java\u9762\u7ecf+DDD\u9886\u57df\u9a71\u52a8\u8bbe\u8ba1\u7406\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content","og_url":"https:\/\/www.wsisp.com\/helps\/123289.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-06T16:24:48+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/123289.html","url":"https:\/\/www.wsisp.com\/helps\/123289.html","name":"LeetCode100+java\u9762\u7ecf+DDD\u9886\u57df\u9a71\u52a8\u8bbe\u8ba1\u7406\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-06T16:24:48+00:00","dateModified":"2026-11-06T16:24:48+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/123289.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/123289.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/123289.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"LeetCode100+java\u9762\u7ecf+DDD\u9886\u57df\u9a71\u52a8\u8bbe\u8ba1\u7406\u89e3"}]},{"@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\/123289","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=123289"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/123289\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=123289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=123289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=123289"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=123289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}