{"id":1566,"date":"2019-07-03T11:15:50","date_gmt":"2019-07-03T03:15:50","guid":{"rendered":"http:\/\/www.puzi7.com\/?p=1566"},"modified":"2019-07-03T11:15:50","modified_gmt":"2019-07-03T03:15:50","slug":"spring-cloud-config-server%e7%9a%84%e9%85%8d%e7%bd%ae%e5%92%8c%e4%bd%bf%e7%94%a8%e4%bb%a5%e5%8f%8a%e9%94%99%e8%af%af%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=1566","title":{"rendered":"Spring cloud Config server\u7684\u914d\u7f6e\u548c\u4f7f\u7528\u4ee5\u53ca\u9519\u8bef\u5206\u6790"},"content":{"rendered":"<span itemprop=\"description\"><p>\u5bf9\u4e8espring cloud\u6709\u4e00\u5b9a\u4e86\u89e3\u4e4b\u540e\uff0c\u6211\u4eec\u4f1a\u53d1\u73b0\uff0cspring cloud config server\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u5b83\u53ef\u4ee5\u8ba9\u4f60\u5f88\u65b9\u4fbf\u7684\u66f4\u65b0\u5404\u4e2a\u670d\u52a1\u7684\u914d\u7f6e\uff0c\u4f46\u662f\u5982\u4f55\u6b63\u786e\u7684\u4f7f\u7528\u8fd9\u4e2a\u670d\u52a1\u5462\uff0c\u8bf7\u770b\u4e0b\u9762\u7684\u4ecb\u7ecd\u3002<br \/>\n\u9996\u5148\u4ecb\u7ecd\u73af\u5883\u4fe1\u606f\uff1a<br \/>\n1. spring cloud version: Greenwich 2.1.6<br \/>\n2. eureka server \u505a\u6ce8\u518c\u4e2d\u5fc3\uff0cconfig server \u505a\u914d\u7f6e\u4e2d\u5fc3<br \/>\n3. \u4e86\u89e3bootstrap.yml\u548capplication.yml\u7684\u52a0\u8f7d\u987a\u5e8f\uff0c\u5bf9\u4e8e\u6ce8\u518c\u548c\u914d\u7f6e\u7684\u52a0\u8f7d\uff0c\u6700\u597d\u653e\u5230bootstrap.yml\u91cc\u8fb9<\/p>\n<p>\u7b2c\u4e00\u6b65\uff0c\u5148\u6dfb\u52a0\u5e76\u914d\u7f6eeureka server<br \/>\n<code><br \/>\nspring:<br \/>\nsecurity:<br \/>\nuser:<br \/>\nname: abc<br \/>\npassword: 123456<br \/>\neureka:<br \/>\ninstance:<br \/>\nhostname: localhost<br \/>\nprefer-ip-address: false<br \/>\nclient:<br \/>\nregister-with-eureka: false<br \/>\nfetch-registry: false<br \/>\nservice-url:<br \/>\ndefault-zone: \thttp:\/\/${spring.security.user.name}:${spring.security.user.password}@${eureka.instance.hostname}:${server.port}\/eureka\/<br \/>\n<\/code><br \/>\n\u7b2c\u4e8c\u6b65\uff0c\u6dfb\u52a0\u5e76\u914d\u7f6econfig server<br \/>\n<code><br \/>\nserver:<br \/>\nport: 8011<br \/>\nspring:<br \/>\napplication:<br \/>\nname: baseservice-config-server<br \/>\nprofiles: default<\/code><\/p>\n<p>devtools:<br \/>\nadd-properties: false<br \/>\ncloud:<br \/>\nconfig:<br \/>\nserver:<br \/>\ngit:<br \/>\nuri: https:\/\/github.com\/alecchyi\/farm-config<br \/>\nusername: xxxxx<br \/>\npassword:<br \/>\nsearch-paths: config-dev<br \/>\ndefault-label: master<br \/>\nbasedir: .\/git_config<\/p>\n<p>fail-fast: true<\/p>\n<p>retry:<br \/>\nmax-attempts: 3<\/p>\n<p>security:<br \/>\nuser:<br \/>\nname: abc<br \/>\npassword: 123456<\/p>\n<p>eureka:<br \/>\ninstance:<br \/>\nappname: baseservice-config-server<br \/>\nclient:<br \/>\nserviceUrl:<br \/>\ndefaultZone: http:\/\/${username}:${password}@eureka-single-server:8010\/eureka\/<\/p>\n<p>\u7b2c\u4e09\u6b65\uff0c\u6dfb\u52a0config client<br \/>\n<code><br \/>\nspring:<br \/>\nprofiles: default, dev<br \/>\ncloud:<br \/>\n<strong>config:<\/strong><br \/>\n<strong><br \/>\nlabel: master<\/strong><br \/>\n<span style=\"background-color: #ff6600;\"><strong><br \/>\n#      uri: http:\/\/abc:123456@127.0.0.1:8011<\/strong><\/span><br \/>\n<strong><br \/>\n<span style=\"background-color: #ff6600;\">discovery:<\/span><\/strong><br \/>\n<span style=\"background-color: #ff6600;\"><br \/>\n<strong><br \/>\nenabled: true<\/strong><\/span><br \/>\n<span style=\"background-color: #ff6600;\"><strong><br \/>\nservice-id: baseservice-config-server<\/strong><\/span><br \/>\n<strong><br \/>\n<span style=\"background-color: #ff6600;\">username: abc<\/span><\/strong><br \/>\n<span style=\"background-color: #ff6600;\"><br \/>\n<strong><br \/>\npassword: 123456<\/strong><\/span><\/code><\/p>\n<p><span style=\"background-color: #ff6600;\"><strong>eureka:<\/strong><\/span><br \/>\n<span style=\"background-color: #ff6600;\"> <strong> client:<\/strong><\/span><br \/>\n<span style=\"background-color: #ff6600;\"> <strong> serviceUrl:<\/strong><\/span><br \/>\n<span style=\"background-color: #ff6600;\"> <strong> defaultZone: http:\/\/${spring.cloud.config.username}:${spring.cloud.config.password}@eureka-single-server:8010\/eureka\/<\/strong><\/span><\/p>\n<p>management:<br \/>\nendpoints:<br \/>\nweb:<br \/>\nexposure:<br \/>\ninclude: health, refresh, info<\/p>\n<p><strong>\u5bf9\u4e8espring cloud\u7684\u8fd9\u4e2a\u7248\u672c\uff0c\u6211\u8fd9\u8fb9\u5b9e\u9a8c\u7684\u7ed3\u679c\u662f\uff1a\uff08spring cloud\u7684\u7248\u672c\u53d8\u5316\u8fd8\u662f\u5f88\u591a\u5751\u7684\uff09<\/strong><\/p>\n<ol>\n<li><strong>config client\u8fd9\u8fb9\uff0c\u5982\u679c\u4f7f\u7528config.uri, \u7136\u540e\u628aeureka\u7684\u914d\u7f6e\u653e\u5230git\u7684\u914d\u7f6e\u6587\u4ef6\u91cc\u8fb9\uff0c\u4f1a\u51fa\u73b0\u4e0b\u8fb9\u7684\u9519\u8bef\u201dspring cloud config server&#8212;No instances found of configserver\u201c \uff0c \u4f46\u662feureka server\u8fd8\u662f\u80fd\u53d1\u73b0\u8fd9\u4e2a\u670d\u52a1\u7684\uff0c\u53ea\u662f\u4f1a\u51fa\u73b0\u8fd9\u4e2a\u9519\u8bef\u800c\u5df2<\/strong><\/li>\n<li><strong>\u5982\u679c\u4f7f\u7528\u4e0a\u6587\u91cc\u8fb9\u7684\u914d\u7f6e\uff0c\u4f7f\u7528discovery.service id, \u90a3\u8fb9\u5c31\u9700\u8981\u628aeureka\u7684\u914d\u7f6e\u4fe1\u606f\u653e\u5230bootstrap.yml\u91cc\u8fb9\uff0c \u800c\u4e14\u4e5f\u4e0d\u4f1a\u51fa\u73b01\u91cc\u8fb9\u7684\u9519\u8bef\u3002<\/strong><\/li>\n<\/ol>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">\u5bf9\u4e8espring cloud\u6709\u4e00\u5b9a\u4e86\u89e3\u4e4b\u540e\uff0c\u6211\u4eec\u4f1a\u53d1\u73b0\uff0cspring cloud conf&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=1566\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,9,12],"tags":[49,63,90,113],"class_list":["post-1566","post","type-post","status-publish","format-standard","hentry","category-32","category-9","category-blog","tag-config","tag-eureka","tag-microservice","tag-spring-cloud","zoom-theme-has-thumb"],"_links":{"self":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/1566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1566"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/1566\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}