{"id":92782,"date":"2020-03-20T02:46:06","date_gmt":"2020-03-19T18:46:06","guid":{"rendered":"http:\/\/4563.org\/?p=92782"},"modified":"2020-03-20T02:46:06","modified_gmt":"2020-03-19T18:46:06","slug":"%e8%af%b7%e9%97%ae-spring-boot-%e7%bd%91%e7%ab%99%e9%83%a8%e7%bd%b2%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=92782","title":{"rendered":"\u8bf7\u95ee Spring Boot \u7f51\u7ad9\u90e8\u7f72\u6700\u4f73\u5b9e\u8df5"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u95ee Spring Boot \u7f51\u7ad9\u90e8\u7f72\u6700\u4f73\u5b9e\u8df5               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wuhuaji <\/span>  <span><i><\/i> 19<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u7531\u4e8e\u5de5\u4f5c\u9700\u8981\uff0c\u8fdb\u5165 Java \u9886\u57df\uff0c\u4f46\u6709 PHP \u540e\u7aef\u7ecf\u9a8c\uff0c\u4f7f\u7528 Spring Boot \u5f00\u53d1\u4e86\u4e00\u4e2a\u7f51\u7ad9\uff0c\u73b0\u5728\u90e8\u7f72\u6709\u4e9b\u95ee\u9898\uff0c\u60f3\u8bf7\u6559\u4e00\u4e0b\u3002<\/p>\n<p>\u67e5\u4e86\u4e00\u4e0b\u8d44\u6599\uff0c\u4f3c\u4e4e\u5206\u4e3a\u4e24\u5927\u6d3e\uff0cjar \u5305\u548c war \u5305\u3002\u5176\u4e2d jar \u5305\u4e2d\u5305\u542b\u4e86 tomcat; war \u5219\u4e0d\u5305\u542b\uff0c\u9700\u8981\u5728\u670d\u52a1\u5668\u90e8\u7f72\u597d tomcat\uff0c\u518d\u628a war \u653e\u5230\u5bf9\u5e94\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u90a3\u4e48\u770b\u6765\uff0cjar \u5305\u662f\u66f4\u4fbf\u6377\u7684\uff0c\u76f4\u63a5 java -jar \u5c31\u53ef\u4ee5\u8fd0\u884c\u3002\u53c8\u56e0\u4e3a\u4e0d\u80fd\u76f4\u63a5\u524d\u53f0\u8fd0\u884c\uff0c\u5c31\u9700\u8981 nohup \u628a\u5176\u653e\u5165\u540e\u53f0\u3002<\/p>\n<p>\u53c8\u67e5\u5230\uff0c\u53ef\u4ee5\u901a\u8fc7 spring-boot-maven-plugin \u63d2\u4ef6\uff0c\u628a jar \u5305\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u653e\u5165\u7cfb\u7edf\u81ea\u8d77\u52a8\u4e2d \/etc\/init.d\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7 start | stop | restart \u7b49\u547d\u4ee4\u63a7\u5236\u3002<\/p>\n<p>\u6211\u53c8\u60f3\u5230\u53ef\u4ee5\u5728\u524d\u7aef\u653e\u4e00\u4e2a Nginx\uff0c\u8f6c\u53d1\u7ed9 tomcat\uff0c\u80fd\u63d0\u5347\u6027\u80fd\u3002<\/p>\n<p>\u6240\u4ee5\u6211\u73b0\u5728\u7684\u505a\u6cd5\u662f\uff0c\u6253\u5305\u6210 jar \u5305\u53ef\u6267\u884c\u6587\u4ef6 -&gt; \u914d\u7f6e\u5f00\u673a\u81ea\u8d77 + Nginx \u63a5\u53d7\u8bf7\u6c42\u8f6c\u53d1\u7ed9 tomcat \u3002\u8fd9\u6837\u7684\u4e00\u5957\u7ec4\u5408\u3002<\/p>\n<p>\u60f3\u8bf7\u95ee\u8fd9\u662f\u5426\u662f\u6700\u4f73\u5b9e\u8df5\uff0c\u8fd8\u6709\u4ec0\u4e48\u9700\u8981\u6ce8\u610f\u7684\u4e48\uff1f\u6bd4\u5982\u50cf\u65e5\u5fd7\u3001\u62a5\u9519\u5565\u7684\u600e\u4e48\u5904\u7406\uff1f<\/p>\n<p>\u8bf7\u6559\u5927\u5bb6<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>10<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"984021\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vinsa <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 google jib \u7f16\u8bd1\u6210 docker image                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"984022\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : wuhuaji <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @vinsa \u8c22\u8c22\uff0c\u540e\u671f\u53ef\u80fd\u4f1a\u4e0a docker\uff0c \u4e0d\u8fc7\u73b0\u5728\u8fd8\u4e0d\u60f3\u592a\u590d\u6742\uff0c\u5148\u628a\u57fa\u672c\u7684\u641e\u6e05\u695a\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"984023\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vinsa <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @wuhuaji \u975e\u5e38\u7b80\u5355\u554a\uff0c\u670d\u52a1\u5668\u5b89\u88c5\u597d docker\uff0c\u5c31 OK \u4e86\u3002 \u6bd4\u4f60\u5199 shell \u542f\u505c\u811a\u672c\u8fd8\u7b80\u5355\u3002<br \/>\u989d\u5916\u7684\u597d\u5904\uff1a\u66f4\u65b0\u90e8\u7f72\u5feb\u3002 \u6bcf\u6b21\u66f4\u65b0\uff0c\u5927\u90e8\u5206\u60c5\u51b5\u4e0b\u90fd\u53ea\u9700\u4f20\u8f93 class \u6587\u4ef6\u90a3\u5c42\uff0c\u4f30\u8ba1\u51e0\u767e K \u3002\u56e0\u4e3a lib\/\u9759\u6001\u6587\u4ef6\u4e4b\u7c7b\u7684\u90fd\u88ab docker image \u5206\u5c42\u7f13\u5b58\u4e86\u3002<\/p>\n<p>\u4f60\u7406\u89e3\u7684\u590d\u6742\u53ef\u80fd\u662f\u5bb9\u5668\u7684\u7f16\u6392\u4e0e\u7ba1\u7406\u3002\u5728\u4f60\u8bbf\u95ee\u91cf\u5230\u4e00\u5b9a\u89c4\u6a21\u4e4b\u524d\uff0c\u5b8c\u5168\u4e0d\u4f1a\u6d89\u53ca\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"984024\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : wuhuaji <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @vinsa \u5bf9\uff0c\u6211\u8bf4\u7684\u590d\u6742\u662f\u5bb9\u5668\u7f16\u6392\u6253\u5305\u7ba1\u7406\u8fd9\u4e9b\uff0c\u56e0\u4e3a\u73b0\u5728\u4e3b\u8981\u60f3\u4e86\u89e3\u539f\u751f\u90e8\u7f72\u5b9e\u8df5\uff0c\u65e5\u540e\u5e94\u7528\u53d8\u5927\uff0c\u81ea\u7136\u4f1a\u8003\u8651 docker \u6765\u505a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"984025\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : oneisall8955 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e24\u79cd\u90fd\u7528\u8fc7\u3002war \u5305\u7ed9 tomcat \u7ba1\u7406\uff0cjar \u5305 JAVA \u547d\u4ee4\u81ea\u5df1\u7ba1\u7406\u3002\u81ea\u5df1\u65b0\u5b66\u7684\u8bdd\uff0c\u6253 jar \u5305\u5427\u6bd4\u8f83\u7b80\u5355                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"984026\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qyvlik <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u63a8\u8350\u4f7f\u7528 docker\uff0c\u8fd9\u6837\u4e0d\u7ba1\u8f93\u51fa\u7684 jar \u8fd8\u662f war \u95ee\u9898\u90fd\u4e0d\u5927<br \/>1. \u4e3a\u4f60\u7684 spring-boot \u9879\u76ee\u7f16\u5199 Dockerfile \uff08\u53ef\u4ee5\u5305\u542b spring-boot \u7684\u6253\u5305\u547d\u4ee4\uff09<br \/>2. \u521b\u5efa {project}-docker \u7684 git \u9879\u76ee\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5c06\u7f16\u6392\u6587\u4ef6\u8fdb\u884c\u4ee3\u7801\u8ddf\u8e2a<br \/> 1. docker-compose.yml \u6587\u4ef6<br \/> 2. nginx \u7684 config \u6587\u4ef6<br \/> 3. .env \u6587\u4ef6\uff0c\u7ba1\u7406\u5173\u952e\u53d8\u91cf\uff0c\u53ef\u4ee5\u901a\u8fc7 docker \u6ce8\u5165\u5230 spring-boot \u7684\u8fd0\u884c\u73af\u5883<br \/> 4. \u5176\u4ed6\u654f\u611f\u4fe1\u606f\u7528 docker secret \u6216\u8005\u52a0\u5bc6\u6587\u4ef6\u7684\u65b9\u5f0f\u5904\u7406<br \/>3. linux \u7cfb\u7edf + docker + docker-compose + git <br \/>4. mysql \u3001redis \u3001\u6d88\u606f\u961f\u5217\u7b49 \u6700\u597d\u4e0d\u8981\u5305\u542b\u5728 {project}-docker\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u65b9\u4fbf\u7684\u5728\u4e0d\u540c\u7684\u670d\u52a1\u5668\u4e0a\u90e8\u7f72\uff0c\u8fc1\u79fb\u3002<\/p>\n<p>\u90e8\u7f72\u7684\u65f6\u5019\uff0c\u914d\u7f6e\u597d\u7cfb\u7edf\u548c docker \u3001docker-compose \u3001git \u516c\u94a5\uff0c\u521b\u5efa\u597d\u76ee\u5f55\uff0c\u5982\u4e0b\u4e09\u884c\u547d\u4ee4\u5c31\u53ef\u4ee5\u5728\u914d\u7f6e\u597d\u7684\u670d\u52a1\u5668\u4e0a\u542f\u52a8\u4f60\u7684 spring-boot<br \/>&#8220;`bash<br \/>git clone {project}-docker<br \/>cd {project}-docker<br \/>docker-compose up<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"984027\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : liqingcan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u82b1 1 \u5929\u65f6\u95f4\u5b66\u4e00\u4e0b docker \u7684\u7b80\u5355\u5b9e\u7528\u3002\u7136\u540e\u76f4\u63a5\u4e0a docker \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"984028\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : wuhuaji <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @qyvlik \u8c22\u8c22\uff0c\u5f88\u8be6\u7ec6<\/p>\n<p>@liqingcan docker \u7b80\u5355\u4f7f\u7528\u6211\u4f1a\u7684\uff1a\uff09                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"984029\" 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>                                                             \u4e00\u822c\u7528 systemd + java -jar app.jar<br \/>\u6216\u8005 docker<br \/>\u6211\u4e5f\u89c1\u8fc7\u7528 pm2 \u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"984030\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kkkkkrua <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Cbdy #9 supervisor \u5462\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u95ee Spring Boot \u7f51\u7ad9&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\/92782"}],"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=92782"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/92782\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=92782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=92782"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=92782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}