{"id":108367,"date":"2020-05-31T08:12:29","date_gmt":"2020-05-31T00:12:29","guid":{"rendered":"http:\/\/4563.org\/?p=108367"},"modified":"2020-05-31T08:12:29","modified_gmt":"2020-05-31T00:12:29","slug":"spring-%e5%ae%98%e7%bd%91%e6%8e%a8%e8%8d%90%e7%9a%84%e5%ad%a6%e4%b9%a0%e9%a1%b9%e7%9b%ae-sagan","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=108367","title":{"rendered":"spring \u5b98\u7f51\u63a8\u8350\u7684\u5b66\u4e60\u9879\u76ee sagan"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  spring \u5b98\u7f51\u63a8\u8350\u7684\u5b66\u4e60\u9879\u76ee sagan               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : feitian124 <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>spring \u7cfb\u6846\u67b6\u5982 spring\uff0cspringboot\uff0cspringcloud \u7b49\u5df2\u6210\u4e3a java \u5f00\u53d1\u7684\u6807\u914d\uff0c\u7b14\u8005\u4e5f\u662f spring \u7cfb\u6846\u67b6\u7684\u591a\u5e74\u7528\u6237\uff0c\u5b83\u4eec\u9075\u5faa\u7edf\u4e00\u7684\u539f\u5219\uff0c\u539f\u7406\u6e05\u6670\uff0c\u5b9e\u73b0\u4f18\u96c5\uff0c \u66f4\u65b0\u53ca\u65f6\uff0c\u5f88\u591a\u6700\u4f73\u5b9e\u8df5\u6162\u6162\u90fd\u6c89\u6dc0\u4e3a\u89c4\u5219\uff0c\u4e3a\u5e7f\u5927 javaer \u63d0\u4f9b\u4e86\u5f88\u591a\u5f00\u7bb1\u5373\u7528\u7684\u4fbf\u5229\uff0c\u5927\u5927\u964d\u4f4e\u5f00\u53d1\u6210\u672c\u3002<\/p>\n<p>\u5b98\u65b9\u7f51\u7ad9\u4e00\u822c\u662f\u5b66\u4e60\u548c\u67e5\u9605\u67d0\u79cd\u6280\u672f\u8d44\u6599\u7684\u9996\u9009, spring \u4e5f\u4e0d\u4f8b\u5916. \u524d\u6bb5\u65f6\u95f4\uff0c\u6211\u60ca\u559c\u7684\u53d1\u73b0\u5b83\u4eec\u7684\u5b98\u65b9\u7f51\u7ad9 \u6539\u7248\u4e86\uff0c \u98ce\u683c\u66f4\u52a0\u6e05\u723d\u8f7b\u91cf\uff0c\u8bbf\u95ee\u901f\u5ea6\u66f4\u5feb\uff0c\u5e03\u5c40\u66f4\u52a0\u6761\u7406\u627e\u6587\u6863\u66f4\u52a0\u65b9\u4fbf\u4e86\u3002\u5728\u8fd9\u4e2a\u524d\u7aef\u6846\u67b6\u5c42\u51fa\u4e0d\u7a77\u7684\u5e74\u4ee3\uff0c\u6211\u6709\u70b9\u597d\u5947 spring \u7684\u5b98\u7f51\u524d\u7aef\u548c\u540e\u7aef\u5206\u522b\u662f\u7528 \u5565\u505a\u7684\uff0c \u53c8\u6709\u5565\u4eae\u70b9\u5462\uff1f \u6211\u4eec\u6765\u4e00\u63a2\u7a76\u7adf\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/06\/20200531_5ed3f33592bad.png\" alt=\"spring \u5b98\u7f51\u63a8\u8350\u7684\u5b66\u4e60\u9879\u76ee sagan\" \/><\/p>\n<p>\u5206\u6790\u7f51\u7ad9\u6280\u672f\u67b6\u6784\u6709\u4e00\u4e2a\u4e0d\u9519\u7684\u5de5\u5177 wappalyzer, \u4e0d\u8fc7\u6211\u4eec\u8fd9\u91cc\u7528\u4e0d\u5230\uff0c\u56e0\u4e3a\u4ed6\u5bb6\u5b98\u7f51\u6e90\u7801\u662f\u5f00\u6e90\u7684\u3002 \u628a\u6e90\u7801 clone \u4e0b\u6765\uff0cREADME \u4e0a\u9762\u4e00\u5f00\u59cb\u5c31\u5199\u7740:<\/p>\n<blockquote>\n<p>In addition to the practical purpose of powering Spring&#8217;s home on the web, this project is designed to serve as a reference application&#8211; resource that developers can use to see how the Spring team have used Spring to implement a real-world app with a few interesting requirements. We hope you&#8217;ll find it useful!<\/p>\n<\/blockquote>\n<p>\u6709\u8da3\uff0c\u8fd9\u4e2a\u9879\u76ee\u662f<strong>\u5b98\u65b9\u63a8\u8350\u7684\u5b66\u4e60\u9879\u76ee<\/strong>\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u628a\u8fd9\u4e2a\u9879\u76ee\u4f5c\u4e3a\u4e00\u4e2a\u53c2\u8003\u9879\u76ee,\u4ece\u8fd9\u4e2a\u9879\u76ee\u5b66\u5230 spring \u56e2\u961f\u600e\u4e48\u7528 spring \u6765\u5b9e\u73b0\u4e00\u4e2a\u771f\u5b9e\u9879\u76ee\u7684\u3002 \u751f\u4ea7\u73af\u5883\u5373 spring \u5b98\u7f51\uff0c\u9700\u6c42\u660e\u786e\uff0c\u4e0d\u7b97\u590d\u6742\u4e5f\u4e0d\u4f1a\u592a\u7b80\u5355\uff0c\u5b98\u65b9\u5b9e\u73b0\u80af\u5b9a\u4ee3\u7801\u8d28\u91cf\u4e5f\u6709\u4fdd\u8bc1\uff0c\u7528\u6765\u5b66\u4e60\u975e\u5e38\u597d\u3002<\/p>\n<pre><code>--sagan   |-- sagan-client   |-- sagan-renderer   |-- sagan-site <\/code><\/pre>\n<p>\u8fd9\u662f\u4e00\u4e2a gradle \u591a\u6a21\u5757\u9879\u76ee\uff0c \u9879\u76ee\u6309\u529f\u80fd\u5212\u5206\u5230 3 \u4e2a\u5b50\u6a21\u5757\u3002\u8fd9\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u5b9e\u8df5\uff0c\u5c06\u9879\u76ee\u4ee3\u7801\u6309\u529f\u80fd\u5206\u6210\u591a\u4e2a\u5b50\u6a21\u5757\u3002<\/p>\n<h3>sagan-client<\/h3>\n<p>\u8fd9\u662f\u524d\u7aef\u6a21\u5757\uff0c\u8be5\u6a21\u5757\u4f7f\u7528 node.js and npm \u548c Webpack \u8fdb\u884c\u7f16\u8bd1, \u5305\u542b\u6240\u6709 web \u7aef\u7684\u8d44\u6e90:<\/p>\n<ul>\n<li>JavaScript \u6a21\u5757\u548c\u4f9d\u8d56<\/li>\n<li>CSS \u6837\u5f0f<\/li>\n<li>\u56fe\u7247\u548c\u5b57\u4f53<\/li>\n<\/ul>\n<p>\u8fd9\u4e2a\u6a21\u5757\u6709 2 \u4e2a\u6709\u8da3\u7684\u70b9\uff0c\u6211\u53ef\u4ee5\u5b66\u4e60\u8fd9\u79cd\u524d\u540e\u7aef\u5206\u79bb\u7684\u65b9\u5f0f:<\/p>\n<ul>\n<li>\u4e00\u662f\u5b83\u7528 gradle \u8c03\u7528 npm \u7f16\u8bd1\u524d\u7aef\uff0c\u4e5f\u5c31\u662f\u8bf4\u524d\u7aef\u4e5f\u96c6\u6210\u5230 gradle \u91cc\u9762<\/li>\n<li>\u4e8c\u662f\u5b83\u5e76\u6ca1\u6709\u7528\u5230 react\uff0cvue \u7b49\u524d\u7aef\u6846\u67b6\u3002\u8fd9\u662f\u4e00\u4e2a\u4f20\u7edf\u7684 jquery \u9879\u76ee\uff0c\u4f46\u770b\u4ee3\u7801\u4ecd\u7136\u5f88\u6e05\u6670\uff0c\u800c\u4e14\u901f\u5ea6\u5f88\u5feb(\u53ef\u76f4\u63a5\u5728\u5b98\u7f51\u4f53\u9a8c)<\/li>\n<\/ul>\n<h3>sagan-renderer<\/h3>\n<p>\u8fd9\u662f\u6e32\u67d3\u6a21\u5757\uff0c\u7b80\u7ea6\u800c\u4e0d\u7b80\u5355\uff0c\u4f5c\u7528\u662f\u5c06 markdown asciidoc \u7b49\u6587\u6863\u6e32\u67d3\u6210 html \u3002 \u8fd9\u91cc\u6211\u4eec\u770b\u5230\u4e86 springboot \u4e00\u4e9b\u7ecf\u5178\u7684\u7528\u6cd5\uff0c \u5982<\/p>\n<ul>\n<li>\n<p>\u914d\u7f6e\u81ea\u52a8\u6ce8\u5165 \uff0cyaml \u4e2d\u7684\u914d\u7f6e\u53ef\u4ee5\u81ea\u52a8\u6ce8\u5165\u5230\u9700\u8981\u7684\u7c7b\u4e2d\uff0c\u5982 <code>RendererProperties<\/code><\/p>\n<\/li>\n<li>\n<p>spring-boot-starter-hateoas HATEOAS \u5373 hypertext as the engine of application state, \u8d85\u5a92\u4f53\u5373\u5e94\u7528\u72b6\u6001\u5f15\u64ce\uff0c\u5b83\u662f Richardson \u63d0\u51fa\u7684 REST \u6210\u719f\u7684\u6a21\u578b\u4e2d\u7684\u7b2c 4 \u5c42\u4e5f\u5c31\u662f\u6700\u9ad8\u4e00\u5c42\u3002 \u5b83\u8981\u6c42\u8d44\u6e90\u4e0d\u4f46\u6709\u94fe\u63a5\u4fe1\u606f\uff0c \u8fd8\u5e94\u8be5\u6709\u53ef\u4ee5\u6267\u884c\u7684\u52a8\u4f5c\u4fe1\u606f\uff0c\u8fd9\u6837\u5ba2\u6237\u7aef\u5c31\u53ef\u4ee5\u52a8\u6001\u53d1\u73b0\u6240\u6709\u5b83\u80fd\u6267\u884c\u7684\u52a8\u4f5c\u3002 spring-boot-starter-hateoas \u5c31\u662f HATEOAS \u7684\u4e00\u4e2a\u5b9e\u73b0, \u8be5\u4ed3\u5e93\u6709\u51e0\u5904\u7528\u4e86\u5b83\uff0c\u5982 <code>GuideResource<\/code>\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fdc\u7a0b\u8c03\u7528 \u975e\u5fae\u670d\u52a1\u67b6\u6784\uff0c\u4e5f\u53ef\u4ee5\u65b9\u4fbf\u7684\u4f7f\u7528\u8fdc\u7a0b\u8c03\u7528\uff0c\u89c1 <code>GithubClient<\/code>. \u5728\u8fd9\u91cc\u53ef\u4ee5\u5b66\u5230\u53e6\u4e00\u4e2a\u5f88\u6709\u7528\u7684\u65b9\u6cd5-\u4f7f\u7528 springboot \u77ed\u77ed\u51e0\u884c\u4ee3\u7801\u4e0b\u8f7d git \u4ed3\u5e93:<\/p>\n<\/li>\n<\/ul>\n<pre><code> \/**   * Download a repository as a zipball   * @param organization the github organization name   * @param repository the repository name   * @return the zipball as raw bytes   *\/  public byte[] downloadRepositoryAsZipball(String organization, String repository) {   try {    byte[] response = this.restTemplate.getForObject(REPO_ZIPBALL_PATH,      byte[].class, organization, repository);    return response;   }   catch (HttpClientErrorException ex) {    throw new GithubResourceNotFoundException(organization, ex);   }  } <\/code><\/pre>\n<h3>sagan-renderer<\/h3>\n<p>\u8fd9\u662f\u6838\u5fc3\u6a21\u5757\uff0c\u5b83\u83b7\u83b7\u53d6\u5185\u5bb9\uff0c\u6e32\u67d3\u6210 html\uff0c\u5c55\u793a\u7ed9\u524d\u7aef\u3002<br \/> \u6211\u4eec\u9996\u5148\u6765\u770b\u770b\u5b83\u662f\u600e\u4e48\u548c <code>sagan-client<\/code> \u5173\u8054\u8d77\u6765\u7684\u3002\u5176\u5b9e\u6bd4\u8f83\u7b80\u5355\uff0c\u5c06\u9759\u6001\u8d44\u6e90\u8def\u5f84\u6dfb\u52a0\u5230 springboot \u914d\u7f6e\u6587\u4ef6\u5373\u53ef\uff0c\u5982\u4e0b:<\/p>\n<pre><code>spring:   profiles: standalone   resources:     static_locations:       - file:${client.dir}\/build\/dist\/   devtools:     restart:       additional_paths:         - ..\/sagan-client\/build\/dist\/       additional_exclude: \"**\/*.js,**\/*.css\" <\/code><\/pre>\n<p>\u7136\u540e\u5b83\u662f\u600e\u4e48\u4f7f\u7528 <code>sagan-client<\/code> \u670d\u52a1\u7684\u5462\uff0c \u89c1 <code>SaganRendererClient<\/code>\u3002\u6b64\u5916\u53ef\u89c1\u9879\u76ee\u5e76\u4e0d\u662f\u56fd\u5185\u6d41\u884c\u7684 mybatis \u800c\u662f jpa\uff0c \u7ecf\u8fc7 springboot-data-jpa \u7684\u52a0\u6301\uff0c\u6709\u5f88\u5f3a\u7684\u7075\u6d3b\u6027\u548c\u53ef\u8bfb\u6027\u3002\u518d\u6211\u7684\u4e0b\u4e00\u4e2a\u9879\u76ee\uff0c\u6211\u53ef\u80fd\u4e5f\u4f1a\u8bd5\u8bd5 jpa \u3002<\/p>\n<pre><code>@Repository public interface PostRepository extends JpaRepository&lt;Post, Long&gt; {      Page&lt;Post&gt; findByCategoryAndDraftFalse(PostCategory category, Pageable pageable);      Page&lt;Post&gt; findByDraftTrue(Pageable pageRequest);      @Query(\"select p from Post p where YEAR(p.publishAt) = ?1 and MONTH(p.publishAt) = ?2 and DAY(p.publishAt) = ?3\")     Page&lt;Post&gt; findByDate(int year, int month, int day, Pageable pageRequest); } <\/code><\/pre>\n<p>\u6700\u540e\uff0csagan-renderer \u662f\u4e00\u4e2a\u5e38\u89c4\u7684 mvc \u9879\u76ee\uff0c\u89c6\u56fe\u5c42\u4f7f\u7528 thymeleaf, \u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u6d4f\u89c8\u5668\u3002\u8fd9\u6837\uff0c\u6574\u4e2a\u6d41\u7a0b\u5c31\u5b8c\u6210\u4e86\u3002<\/p>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u6765\u603b\u7ed3\u4e00\u4e0b\uff0c\u8fd9\u4e2a\u9879\u76ee\u53ef\u4ee5\u5b66\u5230\u4ec0\u4e48.<\/p>\n<ul>\n<li>gradle \u591a\u6a21\u5757\u9879\u76ee\uff0c\u5305\u62ec\u548c npm \u7b49\u524d\u7aef\u7684\u6574\u5408<\/li>\n<li>springboot mvc \u5f00\u53d1\uff0c \u5305\u62ec\u591a\u73af\u5883\u652f\u6301\uff0cjpa\uff0ccache\uff0c \u8fdc\u7a0b\u8c03\u7528\uff0cthymeleaf \u7b49<\/li>\n<li>\u5176\u4ed6\u6700\u4f73\u5b9e\u8df5\uff0c\u5982\u4ee3\u7801\u89c4\u8303\u5305\u62ec\u547d\u540d\u548c\u6ce8\u91ca\uff0c\u811a\u672c\uff0cflyway \u7ba1\u7406\u6570\u636e\u5e93\u53d8\u5316\uff0c\u7b2c\u4e09\u65b9\u670d\u52a1\u5982 github\uff0ccloudfoundry<\/li>\n<\/ul>\n<p>\u611f\u8c22\u60a8\u7684\u9605\u8bfb\uff0c\u6b22\u8fce\u8bbf\u95eeTOP \u5f00\u53d1\u8005\u793e\u533a\u6c9f\u901a\u4ea4\u6d41\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1806228\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jzmws <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6536\u85cf\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1806229\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xyjtou <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Spring is everything                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1806230\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : haosamax <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             spring forever God \uff01                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>spring \u5b98\u7f51\u63a8\u8350\u7684\u5b66\u4e60\u9879\u76ee &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\/108367"}],"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=108367"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/108367\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=108367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=108367"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=108367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}