{"id":3021,"date":"2018-08-29T16:28:54","date_gmt":"2018-08-29T08:28:54","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3021"},"modified":"2018-08-29T16:28:54","modified_gmt":"2018-08-29T08:28:54","slug":"spring-cloud-%e6%95%99%e7%a8%8b%e7%ac%ac%e5%8d%81%e4%b8%89%e7%ab%a0-spring-cloud-config-server%e4%bd%bf%e7%94%a8%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3021","title":{"rendered":"Spring Cloud \u6559\u7a0b\u7b2c\u5341\u4e09\u7ae0 spring-cloud-config-server\u4f7f\u7528\u6559\u7a0b"},"content":{"rendered":"<p>\n\tSpring Cloud \u662f\u4e00\u4e2a\u5168\u5bb6\u6876\uff0c\u63d0\u4f9b\u7684\u5404\u79cd\u7ec4\u4ef6\u6216\u8005\u8bf4\u662f\u63d2\u4ef6\u5f88\u9f50\u5168\u3002\u4f60\u80fd\u60f3\u5230\u7684\u548c\u4e0d\u80fd\u60f3\u4e0d\u5230\u7684\u90fd\u6709\u3002\u524d\u9762\u6211\u5df2\u7ecf\u9646\u9646\u7eed\u7eed\u5199\u4e86 12 \u7ae0\u7684\u6559\u7a0b\uff0c\u4f46\u662f\u5bf9\u4e8e\u6574\u4e2a Spring Cloud \u6765\u8bf4\u624d\u662f\u51b0\u5c71\u4e00\u89d2\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u7ee7\u7eed Spring CLoud \u7684\u7cfb\u5217\u6559\u7a0b\u3002\u672c\u6587\u662f\u7b2c\u5341\u4e09\u7ae0\uff0c\u5bf9 spring-cloud-config-server \u7684\u7b80\u5355\u4f7f\u7528\u6559\u7a0b\u3002\n<\/p>\n<p>\n\t\u524d\u9762\u7684\u51e0\u4e2a\u7ae0\u8282\uff0c\u6211\u4eec\u9646\u9646\u7eed\u7eed\u5199\u4e86\u5f88\u591a\u7684\u670d\u52a1\uff0c\u6bcf\u4e2a\u670d\u52a1\u90fd\u6709\u5355\u72ec\u7684\u914d\u7f6e\u3002\u4f46\u662f\u968f\u7740\u7ae0\u8282\u7684\u6df1\u5165\uff0c\u670d\u52a1\u8d8a\u6765\u8d8a\u591a\u3002\u6211\u4eec\u968f\u7740\u800c\u6765\u9762\u4e34\u7684\u662f\u670d\u52a1\u7684\u7ba1\u7406\u95ee\u9898\u3002\u5728\u5b9e\u9645\u7684\u751f\u4ea7\u73af\u5883\u4e2d\uff0cSpring Cloud \u7684\u5fae\u670d\u52a1\u5b9e\u4f8b\u591a\u8fbe\u4e0a\u5343\u4e2a\uff0c\u6bcf\u4e2a\u670d\u52a1\u90fd\u6709\u4e00\u5957\u914d\u7f6e\u3002\u5b83\u4eec\u5f88\u5206\u6563\uff0c\u5982\u679c\u6211\u60f3\u67e5\u770b\u67d0\u4e00\u4e2a\u670d\u52a1\u7684\u5177\u4f53\u914d\u7f6e\uff0c\u8fd8\u9700\u8981\u767b\u5f55\u5230\u5bf9\u5e94\u7684\u670d\u52a1\u5668\u53bb\u770b\u914d\u7f6e\u6587\u4ef6\uff0c\u6216\u8005\u67e5\u770b\u5177\u4f53\u7248\u672c\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u4ee3\u7801\uff0c\u5bf9\u6bcf\u4e2a\u8fd0\u7ef4\u6765\u8bf4\u5c31\u663e\u5f97\u975e\u5e38\u7684\u9ebb\u70e6\uff0c\u6211\u4eec\u80fd\u4e0d\u80fd\u6709\u4e00\u4e2a\u96c6\u4e2d\u5f0f\u7684\u914d\u7f6e\u4e2d\u5fc3\uff0c\u6765\u7ba1\u7406\u8fd9\u4e9b\u670d\u52a1\u7684\u5404\u4e2a\u914d\u7f6e\u6587\u4ef6\u5462\uff1f\n<\/p>\n<p>\n\t\u7b54\u6848\u5f53\u7136\u662f\u6709\u3002\u6211\u4eec\u80fd\u60f3\u5230\u7684\uff0cSpring Cloud \u90fd\u80fd\u60f3\u5230\u3002\u672c\u6587\u8981\u8bb2\u7684 spring-cloud-config-server \u5c31\u662f\u5bf9\u5404\u4e2a\u670d\u52a1\u7684\u914d\u7f6e\u6587\u4ef6\u7684\u4e00\u4e2a\u96c6\u4e2d\u5f0f\u7ba1\u7406\u7ec4\u4ef6\u3002\n<\/p>\n<p>\n\t\u5173\u4e8e spring-cloud-config-server \u6211\u5c31\u4e0d\u5728\u8be6\u7ec6\u7684\u4ecb\u7ecd\uff0c\u7f51\u4e0a\u6709\u5f88\u591a\u7684\u6587\u7ae0\u6765\u4ecb\u7ecd\u5b83\u3002\u6211\u4eec\u8fd8\u662f\u8ba9\u91cd\u70b9\u653e\u5728\u5982\u4f55\u4f7f\u7528\u4e0a\u5427\u3002\u4e0b\u9762\u6211\u4e00\u8d77\u6765\u4e00\u6b65\u4e00\u6b65\u641e\u5b9a\u5b83\u3002\n<\/p>\n<p>\n\t\u4e3a\u4e86\u65b9\u4fbf\u6f14\u793a spring-cloud-config-server \u7684\u6548\u679c\uff0c\u672c\u6587\u91c7\u7528 git \u7684\u7248\u672c\u63a7\u5236\u7ba1\u7406\u65b9\u5f0f\u6765\u5b58\u653e\u914d\u7f6e\u6587\u4ef6\u3002\n<\/p>\n<p>\n\t\u9996\u5148\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a xttblog-cloud-config \u7684\u4ed3\u5e93\u6216\u6587\u4ef6\u5939\u3002\u5728\u5b83\u4e0b\u9762\u521b\u5efa 3 \u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u5206\u522b\u4ee3\u8868\u5f00\u53d1\u73af\u5883\uff0c\u6d4b\u8bd5\u73af\u5883\uff0c\u751f\u4ea7\u73af\u5883\u3002\u5176\u4e2d xttblog-dev.yml \u6587\u4ef6\u7684\u914d\u7f6e\u5185\u5bb9\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\nsite:\r\n  url: www.xttblog.com\r\n  name: \u4e1a\u4f59\u8349\r\n  active: dev<\/pre>\n<p>\n\txttblog-uat.yml \u6587\u4ef6\u7684\u914d\u7f6e\u5185\u5bb9\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\nsite:\r\n  url: www.xttblog.com\r\n  name: \u4e1a\u4f59\u8349\r\n  active: uat<\/pre>\n<p>\n\txttblog-pat.yml \u6587\u4ef6\u7684\u914d\u7f6e\u5185\u5bb9\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\nsite:\r\n  url: www.xttblog.com\r\n  name: \u4e1a\u4f59\u8349\r\n  active: pat<\/pre>\n<p>\n\t\u4e0d\u65b9\u4fbf\u521b\u5efa\u7684\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6211\u7684\u516c\u5171\u5e93\u4e2d\u7684\u793a\u4f8b\u914d\u7f6e&nbsp;<a href=\"https:\/\/github.com\/xmt1139057136\/xttblog-cloud\/tree\/master\/xttblog-cloud-config\" id=\"b10bba998c13133c783845cb258f67d6-52cf9c42805aad7d3aabcaee74165162a69c75fa\" title=\"xttblog-cloud-config\">xttblog-cloud-config<\/a>\u3002\n<\/p>\n<p>\n\t\u505a\u597d\u4e0a\u9762\u7684\u5de5\u4f5c\u540e\uff0c\u6211\u4eec\u518d\u521b\u5efa\u4e00\u4e2a xttblog-config-server \u5de5\u7a0b\u3002\u5b83\u7684 pom.xml \u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;parent&gt;\r\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\r\n    &lt;version&gt;1.5.13.RELEASE&lt;\/version&gt;\r\n&lt;\/parent&gt;\r\n\r\n&lt;dependencyManagement&gt;\r\n    &lt;dependencies&gt;\r\n        &lt;dependency&gt;\r\n            &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n            &lt;artifactId&gt;spring-cloud-dependencies&lt;\/artifactId&gt;\r\n            &lt;version&gt;Edgware.SR4&lt;\/version&gt;\r\n            &lt;type&gt;pom&lt;\/type&gt;\r\n            &lt;scope&gt;import&lt;\/scope&gt;\r\n        &lt;\/dependency&gt;\r\n    &lt;\/dependencies&gt;\r\n&lt;\/dependencyManagement&gt;\r\n&lt;dependencies&gt;\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;spring-cloud-starter&lt;\/artifactId&gt;\r\n    &lt;\/dependency&gt;\r\n\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;spring-cloud-config-server&lt;\/artifactId&gt;\r\n    &lt;\/dependency&gt;\r\n\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;spring-cloud-starter-eureka-server&lt;\/artifactId&gt;\r\n    &lt;\/dependency&gt;\r\n\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;spring-boot-starter-actuator&lt;\/artifactId&gt;\r\n    &lt;\/dependency&gt;\r\n\r\n    &lt;dependency&gt;\r\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n        &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt;\r\n        &lt;scope&gt;test&lt;\/scope&gt;\r\n    &lt;\/dependency&gt;\r\n&lt;\/dependencies&gt;<\/pre>\n<p>\n\t\u4f5c\u4e3a\u914d\u7f6e\u4e2d\u5fc3\u7684 server \u7aef\uff0c\u5b83\u540c\u6837\u7684\u9700\u8981\u6ce8\u518c\u5230 eureka\uff0c\u5177\u4f53\u7684\u6ce8\u518c\u4e2d\u5fc3\u53c2\u8003\u6211\u4e4b\u524d\u7684\u6587\u7ae0\uff0c\u6216\u8005&nbsp;&nbsp;<a href=\"https:\/\/github.com\/xmt1139057136\/xttblog-cloud\/tree\/master\/xttblog-eureka-server\" id=\"610404df11f1f774ab9dbccd98e28057-08c9977570b3053cfe346ff915969042bc55f9de\" title=\"xttblog-eureka-server\">xttblog-eureka-server<\/a>&nbsp;\u5de5\u7a0b\u3002\n<\/p>\n<p>\n\t\u5bf9\u5e94\u7684&nbsp;application.yml \u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\nserver:\r\n  port: 8877\r\n\r\neureka:\r\n  instance:\r\n    hostname: localhost\r\n  client:\r\n    serviceUrl:\r\n      defaultZone: http:\/\/${eureka.instance.hostname}:8761\/eureka\/\r\n\r\nspring:\r\n  application:\r\n    name: xttblog-config-server\r\n  cloud:\r\n    config:\r\n      server:\r\n        git:\r\n          uri: https:\/\/github.com\/xmt1139057136\/xttblog-cloud.git\r\n#          username:\r\n#          password:\r\n          search-paths: xttblog-cloud-config<\/pre>\n<p>\n\t\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u6211\u4eec\u662f\u8981\u6307\u5b9a git \u7684\u914d\u7f6e\u4ed3\u5e93\u5728\u54ea\u91cc\u3002\u9664\u4e86 git \u5916\uff0cSpring cloud \u540c\u6837\u7684\u652f\u6301 SVN\uff0c\u540e\u9762\u5982\u679c\u6709\u65f6\u95f4\u7684\u8bdd\uff0c\u6211\u4eec\u518d\u6765\u8bf4 SVN \u7684\u4f7f\u7528\u3002\n<\/p>\n<p>\n\t\u542f\u52a8\u7c7b\u4e5f\u5f88\u7b80\u5355\uff0c\u53ea\u662f\u591a\u4e86\u4e00\u4e2a @EnableConfigServer \u6ce8\u89e3\u800c\u5df2\u3002\n<\/p>\n<pre class=\"brush:java;\">\r\n@SpringBootApplication\r\n@EnableDiscoveryClient\r\n@EnableConfigServer\r\npublic class ConfigServerApplication {\r\n    public static void main(String[] args) {\r\n        SpringApplication.run(ConfigServerApplication.class, args);\r\n    }\r\n}<\/pre>\n<p>\n\t\u505a\u5b8c\u6240\u6709\u7684\u5f00\u53d1\u5de5\u4f5c\u540e\uff0c\u6211\u4eec\u542f\u52a8\u5f53\u524d\u8fd9\u4e2a\u5de5\u7a0b\uff0c\u7136\u540e\u5728\u6d4f\u89c8\u5668\u91cc\u8f93\u5165 http:\/\/localhost:8877\/xttblog\/dev \u5c31\u80fd\u8bbf\u95ee\u5230 xttblog-dev.yml \u7684\u5185\u5bb9\u3002\u6539\u53d8\u6700\u540e\u4e00\u4e2a\u53c2\u6570\uff0c\u6211\u4eec\u5c31\u80fd\u8bbf\u95ee\u5176\u4ed6\u5176\u4ed6\u7684\u5185\u5bb9\u3002\n<\/p>\n<p>\n\t\u662f\u4e0d\u662f\u5f88\u60ca\u5947\uff0cSpring Cloud \u5c31\u662f\u8fd9\u4e48\u7b80\u5355\u3002\u5173\u4e8e\u5982\u4f55\u4f7f\u7528\u914d\u7f6e\u4e2d\u5fc3\u8fd9\u4e2a\u670d\u52a1\uff0c\u5176\u4ed6\u670d\u52a1\u5982\u4f55\u901a\u8fc7\u914d\u7f6e\u4e2d\u5fc3\u83b7\u53d6\u5230\u914d\u7f6e\u5185\u5bb9\uff0c\u6211\u4eec\u4e0b\u4e00\u7ae0\u518d\u89c1\uff01<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3021\">Spring Cloud \u6559\u7a0b\u7b2c\u5341\u4e09\u7ae0 spring-cloud-config-server\u4f7f\u7528\u6559\u7a0b<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>Spring Cloud \u662f\u4e00\u4e2a\u5168\u5bb6\u6876\uff0c\u63d0\u4f9b\u7684\u5404\u79cd\u7ec4\u4ef6\u6216\u8005\u8bf4\u662f\u63d2\u4ef6\u5f88\u9f50\u5168\u3002\u4f60\u80fd\u60f3\u5230\u7684\u548c\u4e0d\u80fd\u60f3\u4e0d\u5230\u7684\u90fd\u6709\u3002\u524d\u9762\u6211 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1642,1438,1460,587,588],"class_list":["post-3021","post","type-post","status-publish","format-standard","hentry","category-java","tag-eureka","tag-git","tag-git-","tag-spring-boot","tag-spring-cloud"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3021","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3021"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3021\/revisions"}],"predecessor-version":[{"id":3022,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3021\/revisions\/3022"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}