{"id":218921,"date":"2020-11-27T02:12:27","date_gmt":"2020-11-26T18:12:27","guid":{"rendered":"http:\/\/4563.org\/?p=218921"},"modified":"2020-11-27T02:12:27","modified_gmt":"2020-11-26T18:12:27","slug":"%e5%9c%a8-spring-%e7%9a%84%e9%a1%b9%e7%9b%ae%e4%b8%ad%ef%bc%8c%e6%98%af%e8%bf%94%e5%9b%9e%e5%ae%9e%e4%bd%93entity-%e8%bf%98%e6%98%af-dto-%e5%a5%bd","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=218921","title":{"rendered":"\u5728 spring \u7684\u9879\u76ee\u4e2d\uff0c\u662f\u8fd4\u56de\u5b9e\u4f53(entity) \u8fd8\u662f dto \u597d"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5728 spring \u7684\u9879\u76ee\u4e2d\uff0c\u662f\u8fd4\u56de\u5b9e\u4f53(entity) \u8fd8\u662f dto \u597d               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : glacial <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5404\u4f4d \u8001\u94c1 \u4f60\u4eec\u5728\u505a\u9879\u76ee\u7684\u65f6\u5019\u662f\u600e\u4e48\u8fd4\u56de\u7684\u4fe1\u606f\u7684<\/p>\n<ol>\n<li>\n<p>\u8fd4\u56de entity \u7684\u597d\u5904\u4e0d\u7528\u521b\u5efa\u5f88\u591a\u4e2a dto \u53ef\u4ee5\u8282\u7701\u65f6\u95f4 \u4fee\u6539\u5b57\u6bb5\u65f6\u53ea\u7528\u4fee\u6539\u4e00\u5904\u5373\u53ef<\/p>\n<\/li>\n<li>\n<p>dto \u4e0d\u7528\u66b4\u9732\u8fc7\u591a\u7684\u5b57\u6bb5 \u5f53\u7136\u4e86\u53ef\u4ee5\u901a\u8fc7 JsonIgnore \u53bb\u63a7\u5236 \uff0c\u53ea\u662f\u4e0d\u80fd\u8ddf\u636e\u4e0d\u540c\u7684\u4e1a\u52a1\u573a\u666f\u53bb\u63a7\u5236\u5b57\u6bb5\u663e\u793a, \u7f3a\u70b9\u662f \u4fee\u6539\u5b57\u6bb5\u540e\u90fd\u5f97\u53bb\u4fee\u6539\u5bf9\u5e94\u7684 dto , \u5982\u679c\u7528\u7684\u662f jpa \u8fd8\u5f97\u8fdb\u884c\u8f6c\u6362<\/p>\n<\/li>\n<\/ol>\n<p>\u53ea\u60f3\u7684\u8fd9\u4e9b \u6b22\u8fce\u8865\u5145<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>16<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4430511\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : comsweetcs <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             DTO&#8230;\u6570\u636e\u4f20\u8f93\u5bf9\u8c61\u3002\u4f60\u8bf4\u7684\u4e00\u822c\u662f\u8fd4\u56de VO \u624d\u5bf9\uff0cdto \u4e00\u822c\u662f\u7528\u6765\u533a\u5206\u524d\u7aef\u50cf\u540e\u7aef\u7684\u4f20\u8f93\u5427\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430512\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chendy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e1a\u52a1\u7b80\u5355\u76f4\u63a5\u7684\u8bdd\uff0c\u7528 entity \u53ef\u4ee5<br \/>\u4e1a\u52a1\u590d\u6742\u4e4b\u540e\uff0c\u4e1a\u52a1 \/\u5c55\u793a \u548c \u5b9e\u4f53\u8026\u5408\u4e00\u8d77\u6709\u65f6\u5019\u4f1a\u6bd4\u8f83\u96be\u53d7\uff0c\u62c6 dto \u4f1a\u8212\u670d\u4e00\u4e9b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430513\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : IMCA1024 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             request \u5b9e\u4f53-&gt;DTO \u5b9e\u4f53-&gt;entity \u5b9e\u4f53-&gt;VO \u5b9e\u4f53-&gt;response \u5b9e\u4f53<\/p>\n<p>\u76ee\u524d\u6211\u4eec\u8f6c\u4e86\u5f88\u591a\u5c42\u3002\u3002\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430514\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : anakinsky <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4eec\u516c\u53f8\u5fae\u670d\u52a1\u5185\u90e8\u8c03\u7528\u7684\u8fd4\u56de\u90fd\u662f entity\uff0c\u7ed9\u524d\u7aef\u7684\u90fd\u662f\u6309\u9700\u5c01\u88c5\u6210 VO \u8fd4\u56de                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430515\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : glacial <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @comsweetcs \u5f97\u770b\u81ea\u5df2\u4e1a\u52a1 \u8fd9\u4e2a\u6ca1\u6709\u5f3a\u5236\u8981\u6c42 \u6211\u4e0d\u8981\u5f04\u90a3\u4e48\u591a\u5c42 \u6240\u4ee5 \u53ea\u7528 dto \u5c31\u53ef\u4ee5\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430516\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : glacial <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @IMCA1024 \u90a3\u4f60\u4eec \u7ef4\u62a4\u8d77\u6765\u4e0d\u662f\u5f88 \u9ebb\u70e6                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430517\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ericgui <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @IMCA1024 \u6162\u4e0d\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430518\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : idoggy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u5e95\u5c42 orm \u600e\u4e48\u5f04\u7684\uff0c\u4e00\u5f20\u8868\u4e00\u4e2a class \u7684\u5c31\u5f04\u6210 dto \u81ea\u5df1\u7528\u7684\u65f6\u5019\u518d\u5c01\u88c5\u6210 entity                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430519\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : liuch <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53d6\u51b3\u4e8e\u4f60\u7684\u9879\u76ee\u590d\u6742\u5ea6\u3002\u590d\u6742\u7684\u9879\u76ee\u6709\u5f88\u591a\u5c42\uff0c\u4e0d\u662f\u67e5\u5e93\u51fa\u6765\u5c31\u80fd\u8fd4\u56de\u7684\uff0c\u8fd9\u79cd\u4e0d\u53ea\u6709 dto\uff0cvo                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430520\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gaoli1992 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u89c4\u8303\u89d2\u5ea6\u6765\u8bf4\u4e0d\u5e94\u8be5\u8fd4\u56de entity \u5b9e\u4f53\uff0c\u903c\u8fd1 entity \u4e2d\u5305\u542b\u4e3b\u5efa\u3001\u521b\u5efa\u65f6\u95f4\u3001\u66f4\u65b0\u65f6\u95f4\u7b49\u4fe1\u606f\uff0c\u800c\u8fd9\u4e9b\u4fe1\u606f\u4e0d\u5e94\u8be5\u8ba9\u524d\u7aef\u77e5\u6089\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430521\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : IMCA1024 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ericgui \u6162\u5012\u662f\u4e0d\u6162 \u591a\u5c42\u8f6c\u6362                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430522\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : IMCA1024 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @glacial \u786e\u5b9e\u662f\u3002\u4f46\u6ca1\u529e\u6cd5 \u89c4\u5b9a<br \/>Java\uff0c\u5fae\u670d\u52a1<br \/>\u6211\u4eec Feign \u63a5\u53e3\u6253 client \u5305 \u63a5\u53c2 request \u8fd4\u56de response<br \/>controller \u4f20\u5230 service \u7528 DTO<br \/>mapper \u8fd4\u56de vo                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430523\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : comsweetcs <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @glacial \u53ef\u80fd\u4f60\u7684\u4e1a\u52a1\u6bd4\u8f83\u7b80\u5355\u5427.\u50cf\u5f88\u591a Model \u91cc\u7684\u5b57\u6bb5\uff0c\u5176\u5b9e\u524d\u7aef\u786e\u5b9e\u6ca1\u5fc5\u8981\u5b57\u6bb5\uff0c\u6bd4\u5982\u4e00\u4e9b\u65f6\u95f4\u5b57\u6bb5\u7b49\u3002\u4f7f\u7528 VO \u6216\u8005\u4f60\u7231\u548b\u53eb\u90fd\u884c\uff0c\u91cd\u70b9\u662f\u628a\u8fd9\u90e8\u5206\u4fe1\u606f\u5c4f\u853d\uff0c\u4e00\u6765\u53ef\u4ee5\u505a\u5b89\u5168\u63a7\u5236\uff0c\u4e8c\u6765\u51cf\u5c11\u7f51\u7edc\u4f20\u8f93\u6570\u636e\u91cf\uff0c\u4e09\u6765\u4f20\u5f97\u66f4\u5feb\u3002\u6211\u4eec\u7528\u7684\u5c31\u662f jpa\uff0c\u8f6c\u6362\u6709\u4e00\u5957\u6210\u719f\u7684\u4ee3\u7801\u5c01\u88c5\u65b9\u6848\u5427\uff0c\u5355\u4f53\u7528 BeanUtils\uff0c\u6570\u7ec4\u5217\u8868\u7528 DozerMapper \u5427\uff0c\u81ea\u5df1\u518d\u5c01\u88c5\u4e0b\uff0c\u4e5f\u6ca1\u591a\u9ebb\u70e6\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430524\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Cbdy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/www.v2ex.com\/t\/707841                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430525\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : BuffDog <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u54ce\uff0c\u8fd9\u79cd\u573a\u666f\uff0cC#\u7684\u533f\u540d\u5bf9\u8c61\u662f\u771f\u7684\u9999\uff0c\u867d\u7136 java \u4f7f\u7528 map \u80fd\u5b9e\u73b0\u7c7b\u4f3c\u7684\u64cd\u4f5c\uff0c\u4f46\u8fd8\u662f\u592a\u9ebb\u70e6\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4430526\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Alex5467 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             entity \u6570\u636e\u5305\u542b\u524d\u7aef\u4e0d\u9700\u8981\u7684\u6570\u636e,\u800c\u4e14\u4e5f\u4e0d\u5168\u554a!                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 spring \u7684\u9879\u76ee\u4e2d\uff0c\u662f\u8fd4\u56de&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/218921"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=218921"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/218921\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=218921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=218921"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=218921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}