{"id":101625,"date":"2026-09-07T04:17:16","date_gmt":"2026-09-06T20:17:16","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/101625.html"},"modified":"2026-09-07T04:17:16","modified_gmt":"2026-09-06T20:17:16","slug":"spring%e4%ba%8b%e5%8a%a1%e5%a4%b1%e6%95%88%ef%bc%9atransactional%e8%87%aa%e8%b0%83%e7%94%a8%e4%b8%8d%e7%94%9f%e6%95%88%e7%9a%84%e5%8e%9f%e5%9b%a0%e4%b8%8e4%e5%a4%a7%e5%a4%b1%e6%95%88%e5%9c%ba","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/101625.html","title":{"rendered":"Spring\u4e8b\u52a1\u5931\u6548\uff1a@Transactional\u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e4\u5927\u5931\u6548\u573a\u666f"},"content":{"rendered":"<h2>Spring \u4e8b\u52a1\u5931\u6548&#xff1a;&#064;Transactional \u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e 4 \u5927\u5931\u6548\u573a\u666f<\/h2>\n<p>\u672c\u6587\u901a\u8fc7\u4e00\u4e2a\u300c\u6ce8\u518c\u9001\u79ef\u5206\u300d\u7684\u771f\u5b9e\u6848\u4f8b&#xff0c;\u8bb2\u6e05\u695a Spring \u58f0\u660e\u5f0f\u4e8b\u52a1\u7684\u5e95\u5c42\u673a\u5236&#xff08;AOP \u52a8\u6001\u4ee3\u7406&#xff09;&#xff0c;\u5e76\u7cfb\u7edf\u68b3\u7406 &#064;Transactional \u5931\u6548\u7684 4 \u5927\u573a\u666f\u4e0e\u5bf9\u5e94\u89e3\u51b3\u65b9\u6848\u3002\u8bfb\u5b8c\u4f60\u4f1a\u660e\u767d&#xff1a;\u4e3a\u4ec0\u4e48\u6ce8\u89e3\u660e\u660e\u52a0\u4e86&#xff0c;\u4e8b\u52a1\u5374\u4e0d\u751f\u6548\u3002<\/p>\n<h3>\u4e00\u3001\u95ee\u9898\u6848\u4f8b<\/h3>\n<p>\u7528\u6237\u6ce8\u518c\u63a5\u53e3\u9700\u8981\u505a\u4e24\u4ef6\u4e8b&#xff1a;\u5199\u5165 user \u8868\u3001\u5199\u5165 point \u8868&#xff08;\u9001 500 \u79ef\u5206&#xff09;\u3002\u671f\u671b\u4e24\u8005\u5728\u540c\u4e00\u4e8b\u52a1\u4e2d&#xff0c;\u4efb\u4f55\u4e00\u6b65\u5931\u8d25\u90fd\u6574\u4f53\u56de\u6eda\u3002<\/p>\n<p><span class=\"token annotation punctuation\">&#064;Service<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">UserService<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token annotation punctuation\">&#064;Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">UserMapper<\/span> userMapper<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token annotation punctuation\">&#064;Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">PointMapper<\/span> pointMapper<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;Transactional<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">register<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">User<\/span> user<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        userMapper<span class=\"token punctuation\">.<\/span><span class=\"token function\">insert<\/span><span class=\"token punctuation\">(<\/span>user<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>      <span class=\"token comment\">\/\/ \u5199 user \u8868<\/span><br \/>\n        <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">addPoints<\/span><span class=\"token punctuation\">(<\/span>user<span class=\"token punctuation\">.<\/span><span class=\"token function\">getId<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u9001\u79ef\u5206<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;Transactional<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">addPoints<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">Long<\/span> userId<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        pointMapper<span class=\"token punctuation\">.<\/span><span class=\"token function\">insert<\/span><span class=\"token punctuation\">(<\/span>userId<span class=\"token punctuation\">,<\/span> <span class=\"token number\">500<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u7ebf\u4e0a\u67d0\u5929 point \u8868\u63d2\u5165\u5931\u8d25&#xff0c;\u9884\u671f user \u8868\u4e5f\u56de\u6eda\u3002\u4f46\u7ed3\u679c\u662f&#xff1a;user \u8868\u6570\u636e\u7559\u4e0b\u4e86&#xff0c;\u79ef\u5206\u5374\u6ca1\u5230\u8d26\u3002\u95ee\u9898\u5c31\u51fa\u5728 this.addPoints() \u8fd9\u4e00\u884c\u3002<\/p>\n<h3>\u4e8c\u3001\u539f\u7406\u8be6\u89e3&#xff1a;\u4e8b\u52a1\u9760\u4ee3\u7406\u751f\u6548<\/h3>\n<p>Spring \u7684\u58f0\u660e\u5f0f\u4e8b\u52a1\u4e0d\u662f\u9760\u65b9\u6cd5\u672c\u8eab\u8d77\u4f5c\u7528\u7684&#xff0c;\u800c\u662f\u9760 AOP \u52a8\u6001\u4ee3\u7406\u3002<\/p>\n<ul>\n<li>\u4f60\u5728\u522b\u5904\u901a\u8fc7 &#064;Autowired \u6ce8\u5165\u7684 UserService&#xff0c;\u5176\u5b9e\u662f\u4e00\u4e2a\u4ee3\u7406\u5bf9\u8c61&#xff08;JDK \u52a8\u6001\u4ee3\u7406\u6216 CGLIB \u4ee3\u7406&#xff09;\u3002<\/li>\n<li>\u8c03\u7528 register \u65f6&#xff0c;\u4ee3\u7406\u5bf9\u8c61\u5148\u5f00\u542f\u4e8b\u52a1&#xff0c;\u518d\u6267\u884c\u4f60\u7684\u4e1a\u52a1\u903b\u8f91&#xff0c;\u6700\u540e\u63d0\u4ea4\u6216\u56de\u6eda\u3002<\/li>\n<li>\u4f46 this.addPoints() \u91cc\u7684 this \u6307\u5411\u7684\u662f\u539f\u59cb\u5bf9\u8c61&#xff08;\u76ee\u6807\u5bf9\u8c61&#xff09;&#xff0c;\u4e0d\u662f\u4ee3\u7406\u5bf9\u8c61\u3002\u76f4\u63a5 this \u8c03\u7528\u8df3\u8fc7\u4e86\u4ee3\u7406&#xff0c;addPoints \u4e0a\u7684 &#064;Transactional \u7b49\u4e8e\u6ca1\u5199&#xff0c;\u5b83\u65e2\u5f00\u542f\u4e0d\u4e86\u81ea\u5df1\u7684\u4e8b\u52a1&#xff0c;\u4e5f\u52a0\u5165\u4e0d\u4e86 register \u7684\u4e8b\u52a1\u3002<\/li>\n<\/ul>\n<p>\u4e00\u53e5\u8bdd\u603b\u7ed3&#xff1a;\u540c\u7c7b\u5185\u90e8\u81ea\u8c03\u7528&#xff0c;\u4e8b\u52a1\u6ce8\u89e3\u5168\u90e8\u5931\u6548\u3002<\/p>\n<h3>\u4e09\u3001\u5b9e\u6218\u4ee3\u7801&#xff1a;\u4e09\u79cd\u89e3\u51b3\u65b9\u6848<\/h3>\n<h4>\u65b9\u6848\u4e00&#xff1a;\u62c6\u5230\u72ec\u7acb Bean&#xff08;\u6700\u63a8\u8350&#xff09;<\/h4>\n<p>\u628a\u4e8b\u52a1\u65b9\u6cd5\u62c6\u5230\u53e6\u4e00\u4e2a Service&#xff0c;\u901a\u8fc7\u6ce8\u5165\u8d70\u4ee3\u7406&#xff0c;\u804c\u8d23\u4e5f\u66f4\u6e05\u6670&#xff1a;<\/p>\n<p><span class=\"token annotation punctuation\">&#064;Service<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">PointService<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token annotation punctuation\">&#064;Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">PointMapper<\/span> pointMapper<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;Transactional<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">addPoints<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">Long<\/span> userId<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        pointMapper<span class=\"token punctuation\">.<\/span><span class=\"token function\">insert<\/span><span class=\"token punctuation\">(<\/span>userId<span class=\"token punctuation\">,<\/span> <span class=\"token number\">500<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token annotation punctuation\">&#064;Service<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">UserService<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token annotation punctuation\">&#064;Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">PointService<\/span> pointService<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;Transactional<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">register<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">User<\/span> user<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        userMapper<span class=\"token punctuation\">.<\/span><span class=\"token function\">insert<\/span><span class=\"token punctuation\">(<\/span>user<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        pointService<span class=\"token punctuation\">.<\/span><span class=\"token function\">addPoints<\/span><span class=\"token punctuation\">(<\/span>user<span class=\"token punctuation\">.<\/span><span class=\"token function\">getId<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u8d70\u4ee3\u7406&#xff0c;\u4e8b\u52a1\u751f\u6548<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h4>\u65b9\u6848\u4e8c&#xff1a;\u6ce8\u5165\u81ea\u5df1&#xff08;self-injection&#xff09;<\/h4>\n<p><span class=\"token annotation punctuation\">&#064;Service<\/span><br \/>\n<span class=\"token keyword\">public<\/span> <span class=\"token keyword\">class<\/span> <span class=\"token class-name\">UserService<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token annotation punctuation\">&#064;Autowired<\/span><br \/>\n    <span class=\"token keyword\">private<\/span> <span class=\"token class-name\">UserService<\/span> self<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u6ce8\u5165\u81ea\u5df1\u7684\u4ee3\u7406\u5bf9\u8c61<\/span><\/p>\n<p>    <span class=\"token annotation punctuation\">&#064;Transactional<\/span><br \/>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token function\">register<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">User<\/span> user<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        userMapper<span class=\"token punctuation\">.<\/span><span class=\"token function\">insert<\/span><span class=\"token punctuation\">(<\/span>user<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span><span class=\"token function\">addPoints<\/span><span class=\"token punctuation\">(<\/span>user<span class=\"token punctuation\">.<\/span><span class=\"token function\">getId<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u901a\u8fc7 self \u8d70\u4ee3\u7406<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u80fd\u7528&#xff0c;\u4f46\u81ea\u6211\u6ce8\u5165\u6bd4\u8f83\u7ed5&#xff0c;\u5bb9\u6613\u8ba9\u540e\u6765\u7ef4\u62a4\u7684\u4eba\u770b\u61f5\u3002<\/p>\n<h4>\u65b9\u6848\u4e09&#xff1a;AopContext.currentProxy()<\/h4>\n<p><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">UserService<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token class-name\">AopContext<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">currentProxy<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">addPoints<\/span><span class=\"token punctuation\">(<\/span>user<span class=\"token punctuation\">.<\/span><span class=\"token function\">getId<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u9700\u8981\u5148\u5f00\u542f &#064;EnableAspectJAutoProxy(exposeProxy &#061; true)&#xff0c;\u4fb5\u5165\u6027\u5f3a&#xff0c;\u4e0d\u63a8\u8350\u3002<\/p>\n<h3>\u56db\u3001&#064;Transactional \u5931\u6548\u7684 4 \u5927\u573a\u666f<\/h3>\n<table>\n<tr>\u573a\u666f\u539f\u56e0\u89e3\u51b3<\/tr>\n<tbody>\n<tr>\n<td>\u540c\u7c7b\u81ea\u8c03\u7528<\/td>\n<td>this \u8c03\u7528\u7ed5\u8fc7\u4ee3\u7406<\/td>\n<td>\u62c6 Bean \u6216\u6ce8\u5165\u81ea\u5df1<\/td>\n<\/tr>\n<tr>\n<td>\u65b9\u6cd5\u975e public<\/td>\n<td>\u4ee3\u7406\u53ea\u80fd\u62e6\u622a public \u65b9\u6cd5<\/td>\n<td>\u6539\u4e3a public<\/td>\n<\/tr>\n<tr>\n<td>\u5f02\u5e38\u88ab catch \u541e\u6389<\/td>\n<td>\u5f02\u5e38\u6ca1\u629b\u51fa&#xff0c;\u4ee3\u7406\u611f\u77e5\u4e0d\u5230<\/td>\n<td>\u4e0d\u8981\u541e\u5f02\u5e38&#xff0c;\u6216\u624b\u52a8\u56de\u6eda<\/td>\n<\/tr>\n<tr>\n<td>\u53d7\u68c0\u5f02\u5e38<\/td>\n<td>\u9ed8\u8ba4\u53ea\u5bf9 RuntimeException \u56de\u6eda<\/td>\n<td>\u914d\u7f6e rollbackFor&#xff0c;\u6216\u7edf\u4e00\u629b\u8fd0\u884c\u65f6\u5f02\u5e38<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<p>&#064;Transactional \u751f\u6548\u7684\u672c\u8d28\u662f\u300c\u901a\u8fc7\u4ee3\u7406\u5bf9\u8c61\u8c03\u7528\u300d\u3002\u4e00\u65e6\u7ed5\u8fc7\u4ee3\u7406\u2014\u2014\u6700\u5178\u578b\u7684\u5c31\u662f\u540c\u7c7b this \u81ea\u8c03\u7528\u2014\u2014\u4e8b\u52a1\u5c31\u9759\u9ed8\u5931\u6548\u3002\u6392\u67e5\u4e8b\u52a1\u5931\u6548\u65f6&#xff0c;\u5148\u786e\u8ba4\u8c03\u7528\u662f\u5426\u7ecf\u8fc7\u4e86\u4ee3\u7406&#xff0c;\u518d\u770b\u65b9\u6cd5\u53ef\u89c1\u6027\u3001\u5f02\u5e38\u7c7b\u578b\u548c\u4f20\u64ad\u884c\u4e3a\u3002<\/p>\n<hr \/>\n<p>\u6211\u662f\u65e0\u7fa1&#xff08;\u5c0f\u5251&#xff09;&#xff0c;\u5168\u6808\u504f\u540e\u7aef\u7684\u72ec\u7acb\u5f00\u53d1\u8005\u3002<\/p>\n<p>\u4f5c\u54c1\u96c6&#xff1a;\u65e0\u7fa1 \u00b7 \u72ec\u7acb\u5f00\u53d1\u8005\u4f5c\u54c1\u96c6<\/p>\n<p>\u5982\u679c\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u6b22\u8fce\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u5173\u6ce8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring \u4e8b\u52a1\u5931\u6548&#xff1a;Transactional \u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e 4 \u5927\u5931\u6548\u573a\u666f \u672c\u6587\u901a\u8fc7\u4e00\u4e2a\u300c\u6ce8\u518c\u9001\u79ef\u5206\u300d\u7684\u771f\u5b9e\u6848\u4f8b&#xff0c;\u8bb2\u6e05\u695a Spring \u58f0\u660e\u5f0f\u4e8b\u52a1\u7684\u5e95\u5c42\u673a\u5236&#xff08;AOP \u52a8\u6001\u4ee3\u7406&#xff09;&#xff0c;\u5e76\u7cfb\u7edf\u68b3\u7406 Transactional \u5931\u6548\u7684 4 \u5927\u573a\u666f\u4e0e\u5bf9\u5e94\u89e3\u51b3\u65b9\u6848\u3002\u8bfb\u5b8c\u4f60\u4f1a\u660e\u767d&#xff1a;\u4e3a\u4ec0\u4e48\u6ce8\u89e3\u660e\u660e\u52a0\u4e86&#xff0c;\u4e8b\u52a1\u5374\u4e0d\u751f\u6548\u3002 \u4e00\u3001\u95ee\u9898\u6848\u4f8b<br \/>\n\u7528\u6237\u6ce8\u518c\u63a5\u53e3\u9700\u8981\u505a\u4e24\u4ef6\u4e8b&#xff1a;\u5199\u5165 us<\/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":[99,101,292],"topic":[],"class_list":["post-101625","post","type-post","status-publish","format-standard","hentry","category-server","tag-java","tag-spring","tag-292"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring\u4e8b\u52a1\u5931\u6548\uff1a@Transactional\u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e4\u5927\u5931\u6548\u573a\u666f - \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\/101625.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring\u4e8b\u52a1\u5931\u6548\uff1a@Transactional\u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e4\u5927\u5931\u6548\u573a\u666f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Spring \u4e8b\u52a1\u5931\u6548&#xff1a;Transactional \u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e 4 \u5927\u5931\u6548\u573a\u666f \u672c\u6587\u901a\u8fc7\u4e00\u4e2a\u300c\u6ce8\u518c\u9001\u79ef\u5206\u300d\u7684\u771f\u5b9e\u6848\u4f8b&#xff0c;\u8bb2\u6e05\u695a Spring \u58f0\u660e\u5f0f\u4e8b\u52a1\u7684\u5e95\u5c42\u673a\u5236&#xff08;AOP \u52a8\u6001\u4ee3\u7406&#xff09;&#xff0c;\u5e76\u7cfb\u7edf\u68b3\u7406 Transactional \u5931\u6548\u7684 4 \u5927\u573a\u666f\u4e0e\u5bf9\u5e94\u89e3\u51b3\u65b9\u6848\u3002\u8bfb\u5b8c\u4f60\u4f1a\u660e\u767d&#xff1a;\u4e3a\u4ec0\u4e48\u6ce8\u89e3\u660e\u660e\u52a0\u4e86&#xff0c;\u4e8b\u52a1\u5374\u4e0d\u751f\u6548\u3002 \u4e00\u3001\u95ee\u9898\u6848\u4f8b \u7528\u6237\u6ce8\u518c\u63a5\u53e3\u9700\u8981\u505a\u4e24\u4ef6\u4e8b&#xff1a;\u5199\u5165 us\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/101625.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-06T20:17:16+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=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/101625.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/101625.html\",\"name\":\"Spring\u4e8b\u52a1\u5931\u6548\uff1a@Transactional\u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e4\u5927\u5931\u6548\u573a\u666f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-06T20:17:16+00:00\",\"dateModified\":\"2026-09-06T20:17:16+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/101625.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/101625.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/101625.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring\u4e8b\u52a1\u5931\u6548\uff1a@Transactional\u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e4\u5927\u5931\u6548\u573a\u666f\"}]},{\"@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\u4e8b\u52a1\u5931\u6548\uff1a@Transactional\u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e4\u5927\u5931\u6548\u573a\u666f - \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\/101625.html","og_locale":"zh_CN","og_type":"article","og_title":"Spring\u4e8b\u52a1\u5931\u6548\uff1a@Transactional\u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e4\u5927\u5931\u6548\u573a\u666f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Spring \u4e8b\u52a1\u5931\u6548&#xff1a;Transactional \u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e 4 \u5927\u5931\u6548\u573a\u666f \u672c\u6587\u901a\u8fc7\u4e00\u4e2a\u300c\u6ce8\u518c\u9001\u79ef\u5206\u300d\u7684\u771f\u5b9e\u6848\u4f8b&#xff0c;\u8bb2\u6e05\u695a Spring \u58f0\u660e\u5f0f\u4e8b\u52a1\u7684\u5e95\u5c42\u673a\u5236&#xff08;AOP \u52a8\u6001\u4ee3\u7406&#xff09;&#xff0c;\u5e76\u7cfb\u7edf\u68b3\u7406 Transactional \u5931\u6548\u7684 4 \u5927\u573a\u666f\u4e0e\u5bf9\u5e94\u89e3\u51b3\u65b9\u6848\u3002\u8bfb\u5b8c\u4f60\u4f1a\u660e\u767d&#xff1a;\u4e3a\u4ec0\u4e48\u6ce8\u89e3\u660e\u660e\u52a0\u4e86&#xff0c;\u4e8b\u52a1\u5374\u4e0d\u751f\u6548\u3002 \u4e00\u3001\u95ee\u9898\u6848\u4f8b \u7528\u6237\u6ce8\u518c\u63a5\u53e3\u9700\u8981\u505a\u4e24\u4ef6\u4e8b&#xff1a;\u5199\u5165 us","og_url":"https:\/\/www.wsisp.com\/helps\/101625.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-06T20:17:16+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/101625.html","url":"https:\/\/www.wsisp.com\/helps\/101625.html","name":"Spring\u4e8b\u52a1\u5931\u6548\uff1a@Transactional\u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e4\u5927\u5931\u6548\u573a\u666f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-06T20:17:16+00:00","dateModified":"2026-09-06T20:17:16+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/101625.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/101625.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/101625.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Spring\u4e8b\u52a1\u5931\u6548\uff1a@Transactional\u81ea\u8c03\u7528\u4e0d\u751f\u6548\u7684\u539f\u56e0\u4e0e4\u5927\u5931\u6548\u573a\u666f"}]},{"@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\/101625","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=101625"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/101625\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=101625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=101625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=101625"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=101625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}