﻿{"id":972,"date":"2022-12-22T16:33:15","date_gmt":"2022-12-22T08:33:15","guid":{"rendered":"http:\/\/blog.sway.com.cn\/?p=972"},"modified":"2022-12-22T17:43:21","modified_gmt":"2022-12-22T09:43:21","slug":"%e6%a0%91%e8%8e%93%e6%b4%be%e8%ae%be%e7%bd%ae%e5%bc%80%e6%9c%ba%e8%87%aa%e5%90%af%e5%8a%a8%e7%a8%8b%e5%ba%8fspringboot%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"http:\/\/blog.sway.com.cn\/?p=972","title":{"rendered":"\u6811\u8393\u6d3e\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8\u7a0b\u5e8fspringboot\u7a0b\u5e8f"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>\u7b2c\u4e00\u6b65\uff1a\u5728\/etc\/init.d\/\u76ee\u5f55\u4e0b\u521b\u5efashell\u542f\u52a8\u811a\u672cautojar.sh<\/strong><\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd \/etc\/init.d\/\ntouch autojar.sh\nvi autojar.sh<\/pre>\n\n\n\n<p>autojar.sh\u7684\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/sh\n\n### BEGIN INIT INFO\n# Provides:          raspi.suidian.net.cn\n# Required-Start:    $all\n# Required-Stop:     \n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: autostartup of springboot for RaspberryPi\n### END INIT INFO\n\n#\u7a0b\u5e8f\u540d\nRUN_NAME=\"SpringBoot.jar\"\n\n#jar\u5305\u4f4d\u7f6e\nJAVA_OPTS=\/home\/pi\/Desktop\/raspi-0.0.1-SNAPSHOT.jar\n#\u540e\u53f0\u8fd0\u884c\u65e5\u5fd7\u4f4d\u7f6e\nLOG_OPTS=\/home\/pi\/Desktop\/raspi-nohup.out\n\n#\u5f00\u59cb\u65b9\u6cd5\nstart() {\n\tnohup java -jar $JAVA_OPTS >$LOG_OPTS 2>&amp;1 &amp;\n\techo \"$RUN_NAME started success.\"\n}\n \n#\u7ed3\u675f\u65b9\u6cd5\nstop() {\n\techo \"stopping $RUN_NAME ...\"\n\tkill -9 `ps -ef|grep $JAVA_OPTS|grep -v grep|grep -v stop|awk '{print $2}'`\n}\n\ncase \"$1\" in\n\tstart)\n\t\tstart\n\t\t;;\n\tstop)\n\t\tstop\n\t\t;;\n\trestart)\n\t\tstop\n\t\tstart\n\t\t;;\n\t*)\n\techo \"Userage: $0 {start|stop|restart}\"\n\texit 1\nesac\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7b2c\u4e8c\u6b65\uff1a\u7ed9\u81ea\u52a8\u542f\u52a8\u811a\u672c\u53caspringboot\u7a0b\u5e8f\u6dfb\u52a0\u6267\u884c\u6743\u9650<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> chmod a+x \/etc\/init.d\/autojar.sh\n chmod a+x \/home\/pi\/Desktop\/SpringBoot.jar<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7b2c\u4e09\u90e8\uff1a\u6dfb\u52a0\u5230\u7cfb\u7edf\u670d\u52a1\uff0c\u5e76\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\uff1a<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">update-rc.d autojar.sh defaults 90<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5176\u4ed6<\/h2>\n\n\n\n<p>\u5982\u679c\u542f\u52a8\u65e5\u5fd7\u4e2d\u51fa\u73b0\u4e0b\u56fe\u6240\u793a\u60c5\u51b5\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"http:\/\/blog.sway.com.cn\/wp-content\/uploads\/2022\/12\/image-34.png\"><img loading=\"lazy\" decoding=\"async\" width=\"696\" height=\"488\" src=\"http:\/\/blog.sway.com.cn\/wp-content\/uploads\/2022\/12\/image-34.png\" alt=\"\" class=\"wp-image-976\" srcset=\"http:\/\/blog.sway.com.cn\/wp-content\/uploads\/2022\/12\/image-34.png 696w, http:\/\/blog.sway.com.cn\/wp-content\/uploads\/2022\/12\/image-34-300x210.png 300w\" sizes=\"auto, (max-width: 696px) 100vw, 696px\" \/><\/a><\/figure>\n\n\n\n<p>\u53ef\u80fd\u7531\u4e8e\u6267\u884c\u811a\u672c\u65f6\u5199\u5728\/etc\/profile\u4e2d\u7684\u73af\u5883\u53d8\u91cf\u8fd8\u6ca1\u6709\u751f\u6548\u3002\u6b64\u65f6\u5728\u811a\u672c\u4e2d\u6307\u5b9avava\u6267\u884c\u5668\u7684\u5b8c\u6574bin\u8def\u5f84\u5373\u53ef\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"http:\/\/blog.sway.com.cn\/wp-content\/uploads\/2022\/12\/image-35.png\"><img loading=\"lazy\" decoding=\"async\" width=\"675\" height=\"425\" src=\"http:\/\/blog.sway.com.cn\/wp-content\/uploads\/2022\/12\/image-35.png\" alt=\"\" class=\"wp-image-978\" srcset=\"http:\/\/blog.sway.com.cn\/wp-content\/uploads\/2022\/12\/image-35.png 675w, http:\/\/blog.sway.com.cn\/wp-content\/uploads\/2022\/12\/image-35-300x189.png 300w\" sizes=\"auto, (max-width: 675px) 100vw, 675px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c\u4e00\u6b65\uff1a\u5728\/etc\/init.d\/\u76ee\u5f55\u4e0b\u521b\u5efashell\u542f\u52a8\u811a\u672cautojar.sh autojar.sh\u7684\u5185\u5bb9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-972","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=972"}],"version-history":[{"count":6,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/972\/revisions"}],"predecessor-version":[{"id":1028,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/972\/revisions\/1028"}],"wp:attachment":[{"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=972"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.sway.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}