{"id":1497,"date":"2023-03-25T13:48:26","date_gmt":"2023-03-25T05:48:26","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1497"},"modified":"2023-04-28T20:28:32","modified_gmt":"2023-04-28T12:28:32","slug":"eureka-service-registration-using-host-name-or-ip-address","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/eureka-service-registration-using-host-name-or-ip-address\/","title":{"rendered":"Eureka\u670d\u52a1\u6ce8\u518c\u662f\u91c7\u7528\u4e3b\u673a\u540d\u8fd8\u662fIP\u5730\u5740"},"content":{"rendered":"<p>Spring Cloud\u4f7f\u7528<code>Eureka<\/code>\u8fdb\u884c\u6ce8\u518c\u670d\u52a1\uff0c\u7136\u800c\u6709\u53ef\u80fd\u5f88\u5c11\u5173\u5fc3\u670d\u52a1\u5728\u6ce8\u518c\u5230<code>Eureka Server<\/code>\u65f6\u662f\u91c7\u7528\u7684\u4e3b\u673a\u540d\u7684\u65b9\u5f0f\uff1f\u8fd8\u662fIP\u5730\u5740\u7684\u65b9\u5f0f\uff1f<\/p>\n<p>\u5982\u679c\u91c7\u7528\u4e3b\u673a\u540d\u6ce8\u518c\u65b9\u5f0f\uff0c\u5e76\u4e14\u8be5\u4e3b\u673a\u540d\u4e0d\u53ef\u89e3\u6790\uff0c\u53ef\u80fd\u4f1a\u62a5\u5982\u4e0b\u9519\u8bef\uff1a<\/p>\n<pre><code>Caused by: feign.RetryableException: TEST-APPBLOG executing GET http:\/\/service\/url\n\nCaused by: java.net.UnknownHostException: TEST-APPBLOG<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u6b64\u65f6\u53ef\u4ee5\u914d\u7f6e\u4f18\u5148\u4f7f\u7528IP\u6ce8\u518c<\/p>\n<pre><code class=\"language-yml\"># \u914d\u7f6eEureka Server \u4fe1\u606f\neureka:\n  client:\n    service-url:\n      defaultZone: http:\/\/localhost:8888\/eureka\/\n  instance:\n    # \u81ea\u5b9a\u4e49\u5b9e\u4f8b\u7f16\u53f7\n    instance-id: ${spring.application.name}:${server.port}:@project.version@\n    # \u914d\u7f6e\u4f7f\u7528\u4e3b\u673a\u540d\u6ce8\u518c\u670d\u52a1\n    hostname: node1\n    # \u4f18\u5148\u4f7f\u7528IP\u5730\u5740\u65b9\u5f0f\u8fdb\u884c\u6ce8\u518c\u670d\u52a1\n    prefer-ip-address: true<\/code><\/pre>\n<p>\u53ef\u4ee5\u9009\u62e9\u4e0d\u914d\u7f6e<code>eureka.instance.hostname<\/code>\u53c2\u6570\uff0c\u5982\u679c\u914d\u7f6e\u540e\u4ecd\u60f3\u4f7f\u7528IP Address\u65b9\u5f0f\u8fdb\u884c\u670d\u52a1\u6ce8\u518c\uff0c\u53ef\u4ee5\u901a\u8fc7<code>eureka.instance.prefer-ip-address<\/code>\u53c2\u6570\u6765\u8fdb\u884c\u8bbe\u7f6e\uff0c\u5982\u679c\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3atrue\uff0c\u5219\u4f18\u5148\u4f7f\u7528IP Address\u8fdb\u884c\u670d\u52a1\u6ce8\u518c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring Cloud\u4f7f\u7528Eureka\u8fdb\u884c\u6ce8\u518c\u670d\u52a1\uff0c\u7136\u800c\u6709\u53ef\u80fd\u5f88\u5c11\u5173\u5fc3\u670d\u52a1\u5728\u6ce8\u518c\u5230Eureka Server [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[248],"class_list":["post-1497","post","type-post","status-publish","format-standard","hentry","category-spring-cloud","tag-eureka"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1497"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1497\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}