{"id":124590,"date":"2020-06-26T20:01:12","date_gmt":"2020-06-26T12:01:12","guid":{"rendered":"http:\/\/4563.org\/?p=124590"},"modified":"2020-06-26T20:01:12","modified_gmt":"2020-06-26T12:01:12","slug":"spring-cloud-config-%e5%a6%82%e4%bd%95%e5%8f%aa%e4%bd%bf%e7%94%a8%e6%9c%ac%e5%9c%b0%e7%9b%ae%e5%bd%95%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=124590","title":{"rendered":"Spring Cloud Config \u5982\u4f55\u53ea\u4f7f\u7528\u672c\u5730\u76ee\u5f55\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Spring Cloud Config \u5982\u4f55\u53ea\u4f7f\u7528\u672c\u5730\u76ee\u5f55\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zealinux <\/span>  <span><i><\/i> 12<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6211\u641c\u7d22\u4e86\u4e00\u4e0b\uff0c\u662f\u4f7f\u7528\u73af\u5883\u914d\u7f6e\u6210 native \u3002<\/p>\n<p>Config \u670d\u52a1\u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>spring:     profiles:         active: native  spring:     cloud:         config:             server:                 native:                     search-locations: file:\/\/\/${user.home}\/config-repo <\/code><\/pre>\n<p>config-repo \u7684\u76ee\u5f55\u7ed3\u6784\uff1a<\/p>\n<pre><code>ProjectA\/   datasource\/     ProjectA-prd.yml ProjectB\/   datasource\/     ProjectB-prd.yml <\/code><\/pre>\n<p>\u7136\u540e\u6211\u53d1\u73b0\u6d4f\u89c8\u8d77\u6765\u83b7\u53d6\u4e0d\u5230\u914d\u7f6e<\/p>\n<p><code>http:\/\/&lt;config \u670d\u52a1 IP:Port&gt;\/ProjectA\/prd<\/code><\/p>\n<p>\u5982\u679c\u6539\u6210\uff1a<\/p>\n<p><code>search-locations: file:\/\/\/${user.home}\/config-repo\/**<\/code><\/p>\n<p>\u8fd8\u662f\u4e0d\u884c\u3002 \u4e0d\u77e5\u9053\u6539\u600e\u4e48\u641e\u624d\u5bf9\uff1f<\/p>\n<p>\u662f\u4e0d\u662f <code>native<\/code> \u4e0d\u652f\u6301\u901a\u914d\u7b26\uff1f<\/p>\n<p>\u6211\u7684\u9700\u6c42\u662f\uff0c\u4e0d\u4f9d\u8d56 git\uff0c\u53ea\u7528\u672c\u5730\u76ee\u5f55\u6765\u653e\u6240\u6709\u5fae\u670d\u52a1\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p>\u5982\u679c\u4f9d\u8d56 git\uff0c\u5c82\u4e0d\u662f\u90e8\u7f72\u7ed9\u522b\u4eba\u7528\u7684\u65f6\u5019\uff0c\u8fd8\u5f97\u518d\u90e8\u7f72\u4e00\u5957 git \u670d\u52a1\uff1f\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>11<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2069798\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hangszhang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u914d\u7f6e\u4e2d\u5fc3\u53ea\u628a\u6570\u636e\u5b58\u672c\u5730, \u4f60\u8fd8\u7528\u914d\u7f6e\u4e2d\u5fc3\u5e72\u561b?\u76f4\u63a5\u5199\u6b7b\u5728\u914d\u7f6e\u6587\u4ef6\u91cc\u9762\u4e0d\u5c31\u884c\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2069799\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lzk50136 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 nacos                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2069800\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zealinux <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @hangszhang<\/p>\n<p>\u53e6\u5916\u524d\u51e0\u5929\u53d1\u751f\u8fc7\u8fd9\u6837\u7684\u4e8b\u60c5\uff0c<\/p>\n<p>\uff08\u4ed8\u8d39\u7684\uff09\u7b2c\u4e09\u65b9\u7684\u8fdc\u7a0b\u4ee3\u7801 git \u6258\u7ba1\u7684\u670d\u52a1\u5d29\u4e86\uff0c<br \/>\u5bfc\u81f4 \u914d\u7f6e\u4e2d\u5fc3 \u6302\u4e86\u3002<br \/>\uff08\u8fdc\u7a0b\u8bbf\u95ee\u4e0d\u5230\uff0c\u5c45\u7136\u8fd8\u80fd\u628a\u672c\u5730\u597d\u7684\u7ed9\u5145\u6389\uff0c\u4e5f\u662f\u9189\u4e86\uff09<br \/>\u7136\u540e\u6574\u4e2a spring cloud \u6302\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2069801\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yukiloh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bdd\u8bf4\u914d\u7f6e\u4e2d\u5fc3\u53ef\u4e0d\u53ef\u4ee5\u5199\u591a\u4e2a\u5907\u9009\u2026\u6211\u8fd8\u771f\u7684\u6ca1\u8bd5\u8fc7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2069802\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hantsy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u76f8\u5bf9\u6765\u8bb2\uff0c\u9664\u4e86\u4e00\u4e9b\u4e91\u670d\u52a1\u7279\u6709\u7684 ENV\uff0c\u8fd8\u6709\u52a0\u5bc6\u914d\u7f6e\u5916\uff0cK8s \u7684 ConfigMap \u4e0d\u9519\u3002Git \u8fd9\u79cd Config Server \u5b9e\u9645\u5e94\u7528\u4e2d\u9e21\u808b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2069803\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hantsy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8981\u7528\u4e5f\u53ef\u4ee5\u9009\u62e9\u57fa\u4e8e etcd,consul \u7684\u670d\u52a1\uff0c\u5176\u5b83\u7684\u5c31\u7b97\u4e86\u5427\u3002Configserver \u8fd9\u4e2a\u4e00\u76f4\u6ca1\u5174\u8da3\uff0c\u6211\u63a8\u8350\u7684\u662f\u7528\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\uff0caws \u8fd8\u652f\u6301 Vault \u7c7b\u4f3c\u7684\u52a0\u5bc6\u914d\u7f6e\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2069804\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jorneyr <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             # \u914d\u7f6e\u7684\u662f\u76ee\u5f55<br \/>spring.cloud.config.server.native.search-locations = classpath:\/shared <\/p>\n<p>\u53ef\u4ee5\u53c2\u8003\u8fd9\u4e2a https:\/\/qtdebug.com\/html\/spring-boot\/spring-cloud\/Config.html                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2069805\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : k9990009 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u8bb0\u5f97 prd,native \u4e00\u5757\u5199\u7684\uff0c\u9017\u53f7\u9694\u5f00                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2069806\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cuichaoyang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u542f\u52a8\u53c2\u6570 profiles=dev,native                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2069807\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zealinux <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @jorneyr <br \/>\u4f7f\u7528\u5230\u4e86 classpath\uff0c\u4e5f\u5c31\u662f\u8981\u914d\u7f6e\u6587\u4ef6\u6253\u5305\u5230 jar \u91cc\u9762\u54af\uff1f<\/p>\n<p>\u5982\u679c\u914d\u7f6e\u6587\u4ef6\u540e\u671f\u8981\u6539\u52a8\uff0c\u5c82\u4e0d\u662f\u6bcf\u6b21\u90fd\u8981\u91cd\u65b0\u6253\u5305\u4e00\u4e0b jar \uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2069808\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ipeony <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u89c9\u5f97\u4f60\u7684\u9700\u6c42\u4e0d\u662f\u4e0d\u4f9d\u8d56 git\uff0c\u53ea\u662f\u4e0d\u4f9d\u8d56 git \u8fdc\u7a0b\u670d\u52a1<br \/>\u76f4\u63a5\u914d\u7f6e spring.cloud.config.server.git.uri \u6307\u5411\u672c\u5730\u7684 git \u4ed3\u5e93\u76ee\u5f55\uff08 eg. file:\/\/\/Users\/devUser\/Projects\/Work\/demo-repo \uff09\uff0c\u65e2\u53ef\u4ee5\u6ee1\u8db3 native \u7684\u9700\u6c42\uff0c\u8fd8\u80fd\u505a\u7248\u672c\u7ba1\u7406                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Spring Cloud Conf&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/124590"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=124590"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/124590\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=124590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=124590"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=124590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}