{"id":36381,"date":"2024-11-26T16:26:09","date_gmt":"2024-11-26T08:26:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/36381\/"},"modified":"2024-11-26T16:26:09","modified_gmt":"2024-11-26T08:26:09","slug":"spring-boot-%e6%95%b4%e5%90%88-nacos-%e6%b3%a8%e5%86%8c%e4%b8%ad%e5%bf%83%e6%97%b6%e9%81%87%e5%88%b0%e9%94%99%e8%af%af%ef%bc%8c%e5%a6%82%e4%bd%95%e6%8e%92%e6%9f%a5%e9%97%ae%e9%a2%98%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/36381\/","title":{"rendered":"Spring Boot \u6574\u5408 Nacos \u6ce8\u518c\u4e2d\u5fc3\u65f6\u9047\u5230\u9519\u8bef\uff0c\u5982\u4f55\u6392\u67e5\u95ee\u9898\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173112229274546.jpg\" class=\"aligncenter\" title=\"Spring Boot \u6574\u5408 Nacos \u6ce8\u518c\u4e2d\u5fc3\u65f6\u9047\u5230\u9519\u8bef\uff0c\u5982\u4f55\u6392\u67e5\u95ee\u9898\uff1f\u63d2\u56fe\" alt=\"Spring Boot \u6574\u5408 Nacos \u6ce8\u518c\u4e2d\u5fc3\u65f6\u9047\u5230\u9519\u8bef\uff0c\u5982\u4f55\u6392\u67e5\u95ee\u9898\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>na\u6ce8\u518c\u65f6\u51fa\u73b0\u9519\u8bef\uff0c\u5b9a\u4f4d\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u4f60\u63d0\u5230\u7684\u9519\u8bef\u4fe1\u606f\u8868\u660e\u5728\u4f7f\u7528 spring boot \u6574\u5408 nacos \u6ce8\u518c\u4e2d\u5fc3\u65f6\u9047\u5230\u4e86\u95ee\u9898\u3002\u539f\u56e0\u53ef\u80fd\u662f pom.xml \u6587\u4ef6\u4e2d\u7f3a\u5c11\u5fc5\u8981\u7684\u4f9d\u8d56\u9879\u6216\u5b58\u5728\u914d\u7f6e\u95ee\u9898\u3002<\/p>\n<p><strong>\u68c0\u67e5\u4f9d\u8d56\u9879<\/strong><\/p>\n<p>\u5728\u4f60\u7684 pom.xml \u6587\u4ef6\u4e2d\uff0c\u786e\u4fdd\u5df2\u7ecf\u6dfb\u52a0\u4e86\u4ee5\u4e0b\u4f9d\u8d56\u9879\uff1a<\/p>\n<pre>&lt;dependency&gt;\n    &lt;groupid&gt;com.alibaba.cloud&lt;\/groupid&gt;\n    &lt;artifactid&gt;spring-cloud-starter-alibaba-nacos-discovery&lt;\/artifactid&gt;\n&lt;\/dependency&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u68c0\u67e5\u914d\u7f6e<\/strong><\/p>\n<p>\u5728\u4f60\u7684 application.properties \u6587\u4ef6\u4e2d\uff0c\u914d\u7f6e nacos \u7684\u670d\u52a1\u5668\u5730\u5740\uff1a<\/p>\n<pre>spring.cloud.nacos.discovery.server-addr=localhost:8848<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd8\u8981\u786e\u4fdd\u5df2\u7ecf\u521b\u5efa\u4e86 nacos \u6ce8\u518c\u4e2d\u5fc3\uff0c\u5730\u5740\u548c\u7aef\u53e3\u4e0e\u914d\u7f6e\u7684\u4e00\u81f4\u3002<\/p>\n<p><strong>\u67e5\u770b\u65e5\u5fd7<\/strong><\/p>\n<p>\u8fd0\u884c spring boot \u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u8bf7\u68c0\u67e5\u65e5\u5fd7\u8f93\u51fa\u4e2d\u662f\u5426\u6709\u5176\u4ed6\u9519\u8bef\u63d0\u793a\u3002\u9519\u8bef\u4fe1\u606f\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u51c6\u786e\u5730\u5b9a\u4f4d\u95ee\u9898\u3002<\/p>\n<p><strong>\u5176\u4ed6\u63d0\u793a<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u4f60\u7684 nacos \u6ce8\u518c\u4e2d\u5fc3\u5df2\u7ecf\u542f\u52a8\u5e76\u8fd0\u884c\u3002<\/li>\n<li>\u786e\u8ba4\u4f60\u7684 nacos \u670d\u52a1\u548c\u6ce8\u518c\u6570\u636e\u4e2d\u5fc3\u90fd\u5df2\u914d\u7f6e\u6b63\u786e\u3002<\/li>\n<li>\u68c0\u67e5\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 nacos \u6ce8\u89e3\u6216\u914d\u7f6e\u662f\u5426\u6b63\u786e\u3002<\/li>\n<\/ul>\n<p>\u5982\u679c\u4ecd\u7136\u65e0\u6cd5\u89e3\u51b3\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u65b0\u542f\u52a8 nacos \u6ce8\u518c\u4e2d\u5fc3\u6216\u5e94\u7528\u7a0b\u5e8f\uff0c\u6216\u8005\u68c0\u67e5 nacos \u6587\u6863\u548c\u8bba\u575b\u4ee5\u83b7\u53d6\u66f4\u6df1\u5165\u7684\u652f\u6301\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fSpring Boot \u6574\u5408 Na \u6ce8\u518c\u4e2d\u5fc3\u65f6\u9047\u5230\u9519\u8bef\uff0c\u5982\u4f55\u6392\u67e5\u95ee\u9898\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>na\u6ce8\u518c\u65f6\u51fa\u73b0\u9519\u8bef\uff0c\u5b9a\u4f4d\u89e3\u51b3\u65b9\u6848 \u4f60\u63d0\u5230\u7684\u9519\u8bef\u4fe1\u606f\u8868\u660e\u5728\u4f7f\u7528 spring boot \u6574\u5408 nacos \u6ce8\u518c\u4e2d\u5fc3\u65f6\u9047\u5230\u4e86\u95ee\u9898\u3002\u539f\u56e0\u53ef\u80fd\u662f pom.xml \u6587\u4ef6\u4e2d\u7f3a\u5c11\u5fc5\u8981\u7684\u4f9d\u8d56\u9879\u6216\u5b58\u5728\u914d\u7f6e\u95ee\u9898\u3002 \u68c0\u67e5\u4f9d\u8d56\u9879 \u5728\u4f60\u7684 pom.xml \u6587\u4ef6\u4e2d\uff0c\u786e\u4fdd\u5df2\u7ecf\u6dfb\u52a0\u4e86\u4ee5\u4e0b\u4f9d\u8d56\u9879\uff1a &lt;dependency&gt; &lt;groupid&gt;com.alibaba.cloud&lt;\/groupid&gt; &lt;artifactid&gt;spring-cloud-starter-alibaba-nacos-discovery&lt;\/artifactid&gt; &lt;\/dependency&gt; \u767b\u5f55\u540e\u590d\u5236 \u68c0\u67e5\u914d\u7f6e \u5728\u4f60\u7684 application.properties \u6587\u4ef6\u4e2d\uff0c\u914d\u7f6e nacos \u7684\u670d\u52a1\u5668\u5730\u5740\uff1a spring.cloud.nacos.discovery.server-addr=localhost:8848 \u767b\u5f55\u540e\u590d\u5236 \u8fd8\u8981\u786e\u4fdd\u5df2\u7ecf\u521b\u5efa\u4e86 nacos \u6ce8\u518c\u4e2d\u5fc3\uff0c\u5730\u5740\u548c\u7aef\u53e3\u4e0e\u914d\u7f6e\u7684\u4e00\u81f4\u3002 \u67e5\u770b\u65e5\u5fd7 \u8fd0\u884c spring boot \u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u8bf7\u68c0\u67e5\u65e5\u5fd7\u8f93\u51fa\u4e2d\u662f\u5426\u6709\u5176\u4ed6\u9519\u8bef\u63d0\u793a\u3002\u9519\u8bef\u4fe1\u606f\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u51c6\u786e\u5730\u5b9a\u4f4d\u95ee\u9898\u3002 \u5176\u4ed6\u63d0\u793a \u786e\u4fdd\u4f60\u7684 nacos \u6ce8\u518c\u4e2d\u5fc3\u5df2\u7ecf\u542f\u52a8\u5e76\u8fd0\u884c\u3002 \u786e\u8ba4\u4f60\u7684 nacos \u670d\u52a1\u548c\u6ce8\u518c\u6570\u636e\u4e2d\u5fc3\u90fd\u5df2\u914d\u7f6e\u6b63\u786e\u3002 \u68c0\u67e5\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684 nacos \u6ce8\u89e3\u6216\u914d\u7f6e\u662f\u5426\u6b63\u786e\u3002 \u5982\u679c\u4ecd\u7136\u65e0\u6cd5\u89e3\u51b3\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u65b0\u542f\u52a8 nacos \u6ce8\u518c\u4e2d\u5fc3\u6216\u5e94\u7528\u7a0b\u5e8f\uff0c\u6216\u8005\u68c0\u67e5 nacos \u6587\u6863\u548c\u8bba\u575b\u4ee5\u83b7\u53d6\u66f4\u6df1\u5165\u7684\u652f\u6301\u3002 \u4ee5\u4e0a\u5c31\u662fSpring Boot \u6574\u5408 Na \u6ce8\u518c\u4e2d\u5fc3\u65f6\u9047\u5230\u9519\u8bef\uff0c\u5982\u4f55\u6392\u67e5\u95ee\u9898\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-36381","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/36381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=36381"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/36381\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=36381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=36381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=36381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}