{"id":629,"date":"2020-06-01T16:36:55","date_gmt":"2020-06-01T08:36:55","guid":{"rendered":"https:\/\/blog.humh.cn\/?p=629"},"modified":"2020-06-01T21:39:33","modified_gmt":"2020-06-01T13:39:33","slug":"apollo%e4%b9%8b%e9%85%8d%e7%bd%ae%e5%8f%98%e9%87%8f%e5%8f%96%e5%80%bc%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/blog.humh.cn\/?p=629","title":{"rendered":"Apollo\u4e4b\u914d\u7f6e${}\u53d8\u91cf\u53d6\u503c\u95ee\u9898"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote\"><p>\u539f\u5148\u516c\u53f8\u9047\u5230\u7684\u95ee\u9898\uff0c\u5f53\u65f6\u603b\u7ed3\u7684\u5185\u5bb9\uff0c\u8fd9\u91cc\u8fc1\u79fb\u4e00\u4e0b\u3002<\/p><\/blockquote>\n\n\n\n<h4>\u4e00\u3001\u95ee\u9898\u590d\u73b0<\/h4>\n\n\n\n<p> \u5728\u67d0\u4e2a\u5e94\u7528\u5185\uff0c\u6709\u4e00\u4e2anamespace\uff0capplication.yml \u6709\u5982\u4e0b\u914d\u7f6e <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">spring:\n  application:\n    name: wisdomclass-usercenter\n  datasource:\n    driver-class-name: com.mysql.jdbc.Driver\n    url: jdbc:mysql:\/\/${mysql.db.host}\/${mysql.db.database}?useUnicode=true&amp;characterEncoding=utf-8&amp;mysqlEncoding=utf8&amp;useSSL=false&amp;zeroDateTimeBehavior=convertToNull&amp;allowMultiQueries=true&amp;useServerPrepStmts=true&amp;cachePrepStmts=true&amp;prepStmtCacheSize=250&amp;prepStmtCacheSqlLimit=2048&amp;autoReconnect=true&amp;failOverReadOnly=false\n    username: ${mysql.username}\n    password: ${mysql.password}\n    \neureka:\n  instance:\n    lease-renewal-interval-in-seconds: ${eureka.instance.lease-renewal-interval-in-seconds} #EurekaClient\u5411EurekaServer\u53d1\u9001\u5fc3\u8df3\u65f6\u95f4\u95f4\u9694\n    prefer-ip-address: true\n  client:\n    registerWithEureka: true #\u662f\u5426\u6ce8\u518c\u81ea\u5df1\n    fetchRegistry: ${eureka.client.fetchRegistry}  #\u662f\u5426\u62c9\u53d6\u670d\u52a1\u5217\u8868\n    registry-fetch-interval-seconds: ${eureka.client.registry-fetch-interval-seconds} #Client\u5411Server\u62c9\u53d6\u670d\u52a1\u4fe1\u606f\u7684\u9891\u7387\uff0c\u9632\u6b62\u65b0\u4e0a\u7ebf\u7684\u670d\u52a1\u62c9\u53d6\u4e0d\u5230\n    serviceUrl:\n      #\u6ce8\u518c\u4e2d\u5fc3\u5730\u5740\uff0c\u9ed8\u8ba4zone\u662fdefaultZone\n      defaultZone: ${eureka.client.serviceUrl.defaultZone}<\/pre>\n\n\n\n<p>\u5728\u53e6\u4e00\u4e2anamespace\uff0cbackend.mysql\u4e2d\u6709\u5982\u4e0b\u914d\u7f6e\uff1a <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1118\" height=\"732\" class=\"wp-image-632 lazyload\" title=\"Apollo\u4e4b\u914d\u7f6e${}\u53d8\u91cf\u53d6\u503c\u95ee\u9898\" src=\"data:image\/gif;base64,R0lGODlhAgABAIAAALGxsQAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw==\" data-src=\"https:\/\/file.blog.humh.cn\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22.png\" alt=\"https:\/\/file.blog.humh.cn\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22.png\" data-srcset=\"https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22.png 1118w, https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22-300x196.png 300w, https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22-1024x670.png 1024w, https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22-768x503.png 768w\" sizes=\"(max-width: 1118px) 100vw, 1118px\"><\/figure>\n\n\n\n<p>\u8fd8\u6709\u4e00\u4e2anamespace\uff0cbackend.springcloud\u6709\u5982\u4e0b\u914d\u7f6e\uff1a <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img width=\"1027\" height=\"459\" class=\"wp-image-633 lazyload\" title=\"Apollo\u4e4b\u914d\u7f6e${}\u53d8\u91cf\u53d6\u503c\u95ee\u9898\" src=\"data:image\/gif;base64,R0lGODlhAgABAIAAALGxsQAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw==\" data-src=\"https:\/\/file.blog.humh.cn\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22-1.png\" alt=\"https:\/\/file.blog.humh.cn\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22-1.png\" data-srcset=\"https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22-1.png 1027w, https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22-1-300x134.png 300w, https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22-1-1024x458.png 1024w, https:\/\/file.blog.humh.cn\/wp-content\/uploads\/2020\/06\/d2b5ca33bd970f64a6301fa75ae2eb22-1-768x343.png 768w\" sizes=\"(max-width: 1027px) 100vw, 1027px\"><\/figure>\n\n\n\n<p>\u73b0\u670d\u52a1\u8bfb\u53d6apollo\u53bb\u52a0\u8f7d\u8be5\u5e94\u7528\uff0c\u5728\u914d\u7f6e\u6587\u4ef6\u8fd9\u6837\u914d\u7f6e <br><code>apollo.bootstrap.namespaces:application.yml,backend.mysql,backend.springcloud<\/code><br>\u4f1a\u53d1\u73b0\u670d\u52a1\u542f\u52a8\u62a5\u9519\uff0c\u5f02\u5e38\u7684\u9519\u8bef\u4fe1\u606f\u5982\u4e0b\uff1a <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">2020-02-19 21:22:40.568 WARN  [main] [Jdk14Logger.java:99] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration$EurekaClientConfigurationRefresher': Unsatisfied dependency expressed through field 'autoRegistration'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eurekaAutoServiceRegistration' defined in class path resource [org\/springframework\/cloud\/netflix\/eureka\/EurekaClientAutoConfiguration.class]: Unsatisfied dependency expressed through method 'eurekaAutoServiceRegistration' parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eurekaRegistration' defined in class path resource [org\/springframework\/cloud\/netflix\/eureka\/EurekaClientAutoConfiguration.class]: Unsatisfied dependency expressed through method 'eurekaRegistration' parameter 1; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'eurekaInstanceConfigBean': Could not bind properties to 'EurekaInstanceConfigBean' : prefix=eureka.instance, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'eureka.instance.lease-renewal-interval-in-seconds' to int<\/pre>\n\n\n\n<p>\u53d1\u73b0datasource\u521d\u59cb\u5316\u6210\u529f\uff0c\u4f46eureka\u5931\u8d25\u3002<br>\u5176\u5b9e\u8fd9\u4e2a\u95ee\u9898\u5c31\u662f\u5728\u4f7f\u7528apollo\u8fc7\u7a0b\u4e2d\u5bf9\u4e8e\u8fd9\u79cd\u53d8\u91cf${}\u83b7\u53d6\u65f6\u53ef\u80fd\u5b58\u5728\u7684\u60c5\u51b5\uff0c\u5f53\u53d8\u91cf\u58f0\u660e\u4e0e\u53d8\u91cf\u83b7\u53d6\u540c\u4e00key\u547d\u540d\u65f6\uff0c\u5c31\u5f88\u6709\u53ef\u80fd\u4f1a\u51fa\u73b0\u8fd9\u79cd\u95ee\u9898\u3002<\/p>\n\n\n\n<h4>\u4e8c\u3001\u539f\u56e0\u5206\u6790<\/h4>\n\n\n\n<p>\u8fd9\u91cc\uff0c\u5148\u8bf4\u4e00\u4e0b\uff0c\u5ba2\u6237\u7aef\u5728\u5bf9apollo namespace\u914d\u7f6e\u52a0\u8f7d\u65f6\u7684\u89c4\u5219\uff1a  <\/p>\n\n\n\n<p>\u6839\u636e\u5ba2\u6237\u7aef\u914d\u7f6e\u7684\u201c<strong>apollo.bootstrap.namespaces<\/strong>\u201d\u503c\u6765\u51b3\u5b9a\uff0cnamespace\u5728\u524d\u5148\u52a0\u8f7d\uff0c\u82e5\u6709\u91cd\u590dkey\u7684\u914d\u7f6e\uff0c\u53ea\u4f1a\u52a0\u8f7d\u7b2c\u4e00\u6b21\u7684\u503c\uff0c\u7b2c\u4e8c\u6b21\u7684\u503c\u76f4\u63a5\u8fc7\u6ee4\u6389\u3002\u5b83\u4f1a\u628a\u6240\u6709namespace\u7684\u914d\u7f6e\u52a0\u8f7d\u5b8c\u540e\uff0c\u518d\u53bb\u542f\u52a8spring\u5bb9\u5668\u3002 <\/p>\n\n\n\n<p>\u51fa\u73b0\u4e0a\u8ff0\u95ee\u9898\u7684\u539f\u56e0\u662f\uff0c\u53d8\u91cf\u7684\u547d\u540d\u4e0e\u83b7\u53d6\u7684\u5730\u65b9\u4e3a\u540c\u4e00key\uff0c\u5982\u201ctestKey:${testKey}\u201d\uff0c\u548c\u201ctestKey:1\u201d\u5728\u4e24\u4e2anamespace\uff0c\u5982\u679c\u201ctestKey:${testKey}\u201d\u52a0\u8f7d\u5728\u524d\uff0c\u201ctestKey:1\u201d\u5c31\u4e0d\u4f1a\u518d\u8fdb\u884c\u52a0\u8f7d\uff0c\u7136\u540e\u5728\u5b9e\u4f8b\u5316\u8bfb\u53d6\u914d\u7f6e\u65f6\uff0c\u663e\u7136\u201c${testKey}\u201d\u8fd9\u79cd\u503c\u662f\u9519\u8bef\u7684\uff0c\u5bfc\u81f4\u5f02\u5e38\u3002\u800c\u5982\u679c\u201ctestKey:1\u201d\u5728\u524d\uff0c\u90a3\u4e48\u201ctestKey:${testKey}\u201d\u5c31\u4e0d\u4f1a\u88ab\u52a0\u8f7d\uff0c\u5b9e\u4f8b\u5316\u4e5f\u4e0d\u4f1a\u51fa\u9519\u3002\u800c\u5bf9\u4e8e\u4e0a\u9762\u7684\u201c${mysql.name}\u201d\u7684\u60c5\u51b5\uff0c\u56e0\u4e3aapollo\u5ba2\u6237\u7aef\u4f1a\u5728\u52a0\u8f7d\u5b8c\u6240\u6709namespace\u7684\u914d\u7f6e\u540e\uff0c\u624d\u542f\u52a8\u5bb9\u5668\uff0c\u800c\u4e14\u547d\u540d\u5e76\u4e0d\u91cd\u590d\uff0c\u6240\u4ee5\u53d8\u91cf\u53ef\u4ee5\u6b63\u5e38\u83b7\u53d6\u3002 <\/p>\n\n\n\n<h4>\u4e09\u3001\u603b\u7ed3<\/h4>\n\n\n\n<p>\u5982\u679c\u6709\u53d8\u91cf\u53d6\u503c\u7684\u60c5\u51b5\u65f6\uff0c\u5c3d\u91cf\u4fdd\u8bc1\u53d8\u91cf\u540d\u4e0d\u8981\u4e0e\u53d6\u503c\u7684key\u76f8\u540c\u3002\u82e5\u76f8\u540c\uff0c\u52a1\u5fc5\u4fdd\u8bc1\u53d8\u91cf\u503c\u5728\u524d\u52a0\u8f7d\u3002 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u5148\u516c\u53f8\u9047\u5230\u7684\u95ee\u9898\uff0c\u5f53\u65f6\u603b\u7ed3\u7684\u5185\u5bb9\uff0c\u8fd9\u91cc\u8fc1\u79fb\u4e00\u4e0b\u3002 \u4e00\u3001\u95ee\u9898\u590d\u73b0 \u5728\u67d0\u4e2a\u5e94\u7528\u5185\uff0c\u6709\u4e00\u4e2anamespace\uff0cap [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[51],"tags":[82],"_links":{"self":[{"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/posts\/629"}],"collection":[{"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=629"}],"version-history":[{"count":2,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/posts\/629\/revisions"}],"predecessor-version":[{"id":652,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=\/wp\/v2\/posts\/629\/revisions\/652"}],"wp:attachment":[{"href":"https:\/\/blog.humh.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.humh.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}