{"id":9635,"date":"2023-11-28T21:08:06","date_gmt":"2023-11-28T13:08:06","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=9635"},"modified":"2023-12-06T17:25:13","modified_gmt":"2023-12-06T09:25:13","slug":"springcloud-de-ying-yong-bu-shu-dao-fu-wu-qi-bu-zh","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/springcloud-de-ying-yong-bu-shu-dao-fu-wu-qi-bu-zh\/","title":{"rendered":"SpringCloud\u7684\u5e94\u7528\u90e8\u7f72\u5230\u670d\u52a1\u5668\u6b65\u9aa4\u662f?"},"content":{"rendered":"<p>\u5c06 Spring Cloud \u5e94\u7528\u90e8\u7f72\u5230\u670d\u52a1\u5668\u7684\u6b65\u9aa4\u901a\u5e38\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u9636\u6bb5\uff1a<\/p>\n<h3><a id=\"1%E6%9E%84%E5%BB%BA%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>1. <strong>\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\uff1a<\/strong><\/h3>\n<p>\u786e\u4fdd\u4f60\u7684 Spring Cloud \u5e94\u7528\u7a0b\u5e8f\u5df2\u7ecf\u901a\u8fc7\u6784\u5efa\u5de5\u5177\uff08\u5982 Maven \u6216 Gradle\uff09\u6784\u5efa\uff0c\u5e76\u751f\u6210\u4e86\u53ef\u6267\u884c\u7684 JAR \u6587\u4ef6\u6216 WAR \u6587\u4ef6\u3002\u901a\u5e38\uff0c\u4f60\u53ef\u4ee5\u5728\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e0b\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-bash\">mvn clean package\n<\/code><\/pre>\n<p>\u6216<\/p>\n<pre><code class=\"language-bash\">gradle clean build\n<\/code><\/pre>\n<h3><a id=\"2%E4%B8%8A%E4%BC%A0%E5%88%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>2. <strong>\u4e0a\u4f20\u5230\u670d\u52a1\u5668\uff1a<\/strong><\/h3>\n<p>\u5c06\u6784\u5efa\u597d\u7684 JAR \u6587\u4ef6\u6216 WAR \u6587\u4ef6\u4e0a\u4f20\u5230\u76ee\u6807\u670d\u52a1\u5668\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u5982 <code>scp<\/code>\u3001<code>rsync<\/code> \u6216\u8005\u901a\u8fc7\u5176\u4ed6\u6587\u4ef6\u4f20\u8f93\u65b9\u5f0f\u5c06\u6587\u4ef6\u590d\u5236\u5230\u670d\u52a1\u5668\u7684\u76ee\u6807\u8def\u5f84\u3002<\/p>\n<pre><code class=\"language-bash\">scp target\/your-application.jar user@your-server-ip:\/path\/to\/deploy\n<\/code><\/pre>\n<h3><a id=\"3%E5%AE%89%E8%A3%85-java-runtime%E7%8E%AF%E5%A2%83%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>3. <strong>\u5b89\u88c5Java Runtime\u73af\u5883\uff1a<\/strong><\/h3>\n<p>\u786e\u4fdd\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86\u9002\u5f53\u7248\u672c\u7684 Java Runtime \u73af\u5883\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u5e94\u7528\u7a0b\u5e8f\u7684\u8981\u6c42\u5b89\u88c5 OpenJDK \u6216 Oracle JDK\u3002<\/p>\n<h3><a id=\"4%E8%BF%90%E8%A1%8C%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>4. <strong>\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\uff1a<\/strong><\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728\u670d\u52a1\u5668\u4e0a\u8fd0\u884c Spring Cloud \u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<pre><code class=\"language-bash\">java -jar your-application.jar\n<\/code><\/pre>\n<p>\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u5728\u670d\u52a1\u5668\u4e0a\u6b63\u5e38\u542f\u52a8\uff0c\u5e76\u68c0\u67e5\u63a7\u5236\u53f0\u8f93\u51fa\u4ee5\u67e5\u770b\u662f\u5426\u6709\u9519\u8bef\u6216\u5f02\u5e38\u3002<\/p>\n<h3><a id=\"5%E9%85%8D%E7%BD%AE%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>5. <strong>\u914d\u7f6e\u5e94\u7528\u7a0b\u5e8f\uff1a<\/strong><\/h3>\n<p>\u6839\u636e\u90e8\u7f72\u73af\u5883\u7684\u4e0d\u540c\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u8c03\u6574\u5e94\u7528\u7a0b\u5e8f\u7684\u914d\u7f6e\u3002\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u53c2\u6570\u3001\u73af\u5883\u53d8\u91cf\u6216\u5916\u90e8\u914d\u7f6e\u6587\u4ef6\u6765\u6307\u5b9a\u4e0d\u540c\u7684\u914d\u7f6e\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-bash\">java -jar your-application.jar --spring.profiles.active=production\n<\/code><\/pre>\n<h3><a id=\"6%E4%BD%BF%E7%94%A8%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E8%AE%BE%E7%BD%AE%E5%9F%9F%E5%90%8D%E5%92%8C-ssl%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>6. <strong>\u4f7f\u7528\u53cd\u5411\u4ee3\u7406\u8bbe\u7f6e\u57df\u540d\u548cSSL\uff1a<\/strong><\/h3>\n<p>\u5982\u679c\u4f60\u8ba1\u5212\u901a\u8fc7\u57df\u540d\u8bbf\u95ee\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5e0c\u671b\u4f7f\u7528 SSL \u8fdb\u884c\u5b89\u5168\u8bbf\u95ee\uff0c\u901a\u5e38\u4f1a\u4f7f\u7528\u53cd\u5411\u4ee3\u7406\uff08\u5982 Nginx \u6216 Apache\uff09\u6765\u914d\u7f6e\u57df\u540d\u548c SSL \u8bc1\u4e66\u3002\u5728\u53cd\u5411\u4ee3\u7406\u4e2d\u914d\u7f6e\u4ee3\u7406\u89c4\u5219\uff0c\u5c06\u8bf7\u6c42\u8f6c\u53d1\u5230 Spring Cloud \u5e94\u7528\u7a0b\u5e8f\u7684\u7aef\u53e3\u3002<\/p>\n<h3><a id=\"7%E9%85%8D%E7%BD%AE%E6%95%B0%E6%8D%AE%E5%BA%93%E5%92%8C%E5%85%B6%E4%BB%96%E5%A4%96%E9%83%A8%E6%9C%8D%E5%8A%A1%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>7. <strong>\u914d\u7f6e\u6570\u636e\u5e93\u548c\u5176\u4ed6\u5916\u90e8\u670d\u52a1\uff1a<\/strong><\/h3>\n<p>\u5982\u679c\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u4f9d\u8d56\u4e8e\u6570\u636e\u5e93\u6216\u5176\u4ed6\u5916\u90e8\u670d\u52a1\uff0c\u786e\u4fdd\u5728\u670d\u52a1\u5668\u4e0a\u914d\u7f6e\u4e86\u76f8\u5e94\u7684\u6570\u636e\u5e93\u3001\u6d88\u606f\u961f\u5217\u7b49\u670d\u52a1\uff0c\u5e76\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u6b63\u786e\u914d\u7f6e\u8fde\u63a5\u4fe1\u606f\u3002<\/p>\n<h3><a id=\"8%E7%9B%91%E6%8E%A7%E5%92%8C%E6%97%A5%E5%BF%97%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>8. <strong>\u76d1\u63a7\u548c\u65e5\u5fd7\uff1a<\/strong><\/h3>\n<p>\u914d\u7f6e\u9002\u5f53\u7684\u76d1\u63a7\u548c\u65e5\u5fd7\u8bb0\u5f55\uff0c\u4ee5\u4fbf\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u76d1\u89c6\u5e94\u7528\u7a0b\u5e8f\u7684\u6027\u80fd\u3001\u72b6\u6001\u548c\u9519\u8bef\u3002\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u5982 Prometheus\u3001Grafana \u6216 ELK Stack \u6765\u5b9e\u73b0\u76d1\u63a7\u548c\u65e5\u5fd7\u8bb0\u5f55\u3002<\/p>\n<h3><a id=\"9%E8%AE%BE%E7%BD%AE%E8%87%AA%E5%90%AF%E5%8A%A8%EF%BC%88%E5%8F%AF%E9%80%89%EF%BC%89%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>9. <strong>\u8bbe\u7f6e\u81ea\u542f\u52a8\uff08\u53ef\u9009\uff09\uff1a<\/strong><\/h3>\n<p>\u5982\u679c\u5e0c\u671b\u5e94\u7528\u7a0b\u5e8f\u5728\u670d\u52a1\u5668\u542f\u52a8\u65f6\u81ea\u52a8\u542f\u52a8\uff0c\u53ef\u4ee5\u914d\u7f6e\u7cfb\u7edf\u670d\u52a1\u6216\u4f7f\u7528\u5de5\u5177\u5982 <code>systemd<\/code> \u6216 <code>init.d<\/code>\u3002\u521b\u5efa\u4e00\u4e2a\u542f\u52a8\u811a\u672c\u6216\u670d\u52a1\u6587\u4ef6\uff0c\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u80fd\u591f\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u81ea\u52a8\u8fd0\u884c\u3002<\/p>\n<h3><a id=\"10%E6%B5%8B%E8%AF%95%E5%92%8C%E9%AA%8C%E8%AF%81%EF%BC%9A\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>10. <strong>\u6d4b\u8bd5\u548c\u9a8c\u8bc1\uff1a<\/strong><\/h3>\n<p>\u5728\u751f\u4ea7\u73af\u5883\u4e4b\u524d\uff0c\u786e\u4fdd\u5728\u6d4b\u8bd5\u73af\u5883\u4e2d\u9a8c\u8bc1\u4e86\u5e94\u7528\u7a0b\u5e8f\u7684\u90e8\u7f72\uff0c\u5e76\u8fdb\u884c\u5fc5\u8981\u7684\u6027\u80fd\u6d4b\u8bd5\u548c\u96c6\u6210\u6d4b\u8bd5\u3002<\/p>\n<p>\u4ee5\u4e0a\u6b65\u9aa4\u53ef\u80fd\u4f1a\u6839\u636e\u4f60\u7684\u5177\u4f53\u90e8\u7f72\u73af\u5883\u548c\u9700\u6c42\u800c\u6709\u6240\u4e0d\u540c\u3002\u5728\u90e8\u7f72\u751f\u4ea7\u73af\u5883\u4e4b\u524d\uff0c\u52a1\u5fc5\u4ed4\u7ec6\u6d4b\u8bd5\u548c\u9a8c\u8bc1\u5e94\u7528\u7a0b\u5e8f\uff0c\u4ee5\u786e\u4fdd\u5176\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u7684\u7a33\u5b9a\u6027\u548c\u53ef\u9760\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c06 Spring Cloud \u5e94\u7528\u90e8\u7f72\u5230\u670d\u52a1\u5668\u7684\u6b65\u9aa4\u901a\u5e38\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u9636\u6bb5\uff1a 1. \u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\uff1a \u786e\u4fdd\u4f60\u7684 S [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[117],"tags":[],"class_list":["post-9635","post","type-post","status-publish","format-standard","hentry","category-springcloud"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/9635","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=9635"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/9635\/revisions"}],"predecessor-version":[{"id":16747,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/9635\/revisions\/16747"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=9635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=9635"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=9635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}