{"id":7963,"date":"2023-11-28T20:08:16","date_gmt":"2023-11-28T12:08:16","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=7963"},"modified":"2023-12-05T16:01:20","modified_gmt":"2023-12-05T08:01:20","slug":"springboot-de-spring-data-rest-le-jie-ma","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/springboot-de-spring-data-rest-le-jie-ma\/","title":{"rendered":"SpringBoot \u7684 Spring Data REST \u4e86 \u89e3\u5417\uff1f"},"content":{"rendered":"<p>\u662f\u7684\uff0c\u6211\u4e86\u89e3 Spring Data REST\u3002Spring Data REST \u662f Spring Data \u9879\u76ee\u7684\u4e00\u90e8\u5206\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u8f7b\u677e\u521b\u5efa\u57fa\u4e8e REST \u98ce\u683c\u7684API\u7684\u65b9\u5f0f\u3002\u5b83\u901a\u8fc7\u5c06 Spring Data \u5b58\u50a8\u5e93\uff08Repository\uff09\u81ea\u52a8\u5bfc\u51fa\u4e3a RESTful \u7aef\u70b9\uff0c\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u800c\u5f3a\u5927\u7684\u65b9\u5f0f\u6765\u66b4\u9732\u548c\u64cd\u4f5c\u6570\u636e\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f Spring Data REST \u7684\u4e00\u4e9b\u5173\u952e\u7279\u70b9\u548c\u6982\u5ff5\uff1a<\/p>\n<ol>\n<li>\n<strong>\u81ea\u52a8\u66b4\u9732\u5b58\u50a8\u5e93\uff1a<\/strong><\/p>\n<ul>\n<li>Spring Data REST \u53ef\u4ee5\u81ea\u52a8\u5c06 Spring Data \u5b58\u50a8\u5e93\uff08\u4f8b\u5982 JPA\u3001MongoDB\u3001Elasticsearch \u7b49\uff09\u8f6c\u6362\u4e3a RESTful \u7aef\u70b9\u3002\u8fd9\u610f\u5473\u7740\uff0c\u53ea\u9700\u5b9a\u4e49\u4e00\u4e2a\u5b58\u50a8\u5e93\u63a5\u53e3\uff0cSpring Data REST \u5c31\u4f1a\u81ea\u52a8\u4e3a\u4f60\u521b\u5efa RESTful API\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u652f\u6301\u591a\u79cd\u5b58\u50a8\u540e\u7aef\uff1a<\/strong><\/p>\n<ul>\n<li>Spring Data REST \u652f\u6301\u591a\u79cd\u6570\u636e\u5b58\u50a8\u540e\u7aef\uff0c\u5305\u62ec\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff08JPA\uff09\u3001NoSQL \u6570\u636e\u5e93\uff08MongoDB\u3001Cassandra\uff09\u3001\u641c\u7d22\u5f15\u64ce\uff08Elasticsearch\uff09\u7b49\u3002\u4e0d\u540c\u7684\u5b58\u50a8\u5e93\u7c7b\u578b\u90fd\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u914d\u7f6e\u8fdb\u884c\u66b4\u9732\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u9ed8\u8ba4\u7aef\u70b9\u89c4\u5219\uff1a<\/strong><\/p>\n<ul>\n<li>Spring Data REST \u6839\u636e\u9ed8\u8ba4\u89c4\u5219\u521b\u5efa RESTful \u7aef\u70b9\u3002\u4f8b\u5982\uff0c\u4e00\u4e2a JPA \u5b58\u50a8\u5e93 <code>PersonRepository<\/code> \u5c06\u4f1a\u66b4\u9732\u4e3a <code>\/persons<\/code> \u7684\u7aef\u70b9\u3002\u8fd9\u79cd\u9ed8\u8ba4\u89c4\u5219\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u8fdb\u884c\u4fee\u6539\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u81ea\u5b9a\u4e49\u7aef\u70b9\uff1a<\/strong><\/p>\n<ul>\n<li>\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49\u63a7\u5236\u5668\u6765\u6269\u5c55\u6216\u4fee\u6539 Spring Data REST \u66b4\u9732\u7684\u7aef\u70b9\u3002\u8fd9\u6837\uff0c\u4f60\u53ef\u4ee5\u81ea\u5b9a\u4e49\u7aef\u70b9\u7684\u884c\u4e3a\u3001\u9a8c\u8bc1\u3001\u5b89\u5168\u6027\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u6295\u5f71\u548c\u6295\u5f71\u96c6\u5408\uff1a<\/strong><\/p>\n<ul>\n<li>Spring Data REST \u652f\u6301\u6295\u5f71\uff08Projection\uff09\u548c\u6295\u5f71\u96c6\u5408\uff08Projection Collection\uff09\uff0c\u8fd9\u4f7f\u5f97\u5728\u83b7\u53d6\u6570\u636e\u65f6\u53ea\u8fd4\u56de\u6240\u9700\u7684\u5b57\u6bb5\uff0c\u51cf\u5c11\u7f51\u7edc\u4f20\u8f93\u7684\u6570\u636e\u91cf\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u81ea\u5b9a\u4e49\u67e5\u8be2\uff1a<\/strong><\/p>\n<ul>\n<li>Spring Data REST \u5141\u8bb8\u5728\u5b58\u50a8\u5e93\u4e0a\u5b9a\u4e49\u81ea\u5b9a\u4e49\u67e5\u8be2\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u5c06\u81ea\u52a8\u6620\u5c04\u5230 RESTful \u7aef\u70b9\u3002\u8fd9\u4f7f\u5f97\u53ef\u4ee5\u901a\u8fc7 HTTP \u8bf7\u6c42\u53c2\u6570\u8fdb\u884c\u67e5\u8be2\uff0c\u4f8b\u5982 <code>\/persons\/search\/findByLastName?name=Smith<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u5206\u9875\u548c\u6392\u5e8f\uff1a<\/strong><\/p>\n<ul>\n<li>Spring Data REST \u9ed8\u8ba4\u652f\u6301\u5206\u9875\u548c\u6392\u5e8f\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bf7\u6c42\u53c2\u6570\u6765\u63a7\u5236\u8fd4\u56de\u7ed3\u679c\u7684\u6570\u91cf\u548c\u6392\u5e8f\u65b9\u5f0f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong>\u4e8b\u4ef6\u673a\u5236\uff1a<\/strong><\/p>\n<ul>\n<li>Spring Data REST \u63d0\u4f9b\u4e86\u4e8b\u4ef6\u673a\u5236\uff0c\u5141\u8bb8\u5f00\u53d1\u8005\u5728\u8d44\u6e90\u7684\u521b\u5efa\u3001\u66f4\u65b0\u3001\u5220\u9664\u7b49\u4e8b\u4ef6\u53d1\u751f\u65f6\u6267\u884c\u81ea\u5b9a\u4e49\u903b\u8f91\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>Spring Data REST \u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u4fbf\u7684\u65b9\u5f0f\u6765\u6784\u5efa\u548c\u516c\u5f00 RESTful API\uff0c\u51cf\u5c11\u4e86\u5927\u90e8\u5206\u4f20\u7edf\u7684\u624b\u52a8\u7f16\u5199 API \u4ee3\u7801\u7684\u5de5\u4f5c\u3002\u5b83\u662f Spring \u751f\u6001\u7cfb\u7edf\u4e2d\u6784\u5efa RESTful \u670d\u52a1\u7684\u6709\u529b\u5de5\u5177\u4e4b\u4e00\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u662f\u7684\uff0c\u6211\u4e86\u89e3 Spring Data REST\u3002Spring Data REST \u662f Spring Data  [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[100],"tags":[],"class_list":["post-7963","post","type-post","status-publish","format-standard","hentry","category-springboot"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/7963","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=7963"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/7963\/revisions"}],"predecessor-version":[{"id":16558,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/7963\/revisions\/16558"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=7963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=7963"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=7963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}