日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring Cloud Alibaba - 19 Nacos Config配置中心加载不同微服务的通用配置的两种方式

發布時間:2025/3/21 javascript 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring Cloud Alibaba - 19 Nacos Config配置中心加载不同微服务的通用配置的两种方式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • Pre
  • 實現
    • 方式一 通過 shared-dataids 方式
    • 方式二 通過 ext-config方式
  • 配置文件優先級
  • 源碼


Pre

Spring Cloud Alibaba - 18 Nacos Config配置中心加載相同微服務的不同環境下的通用配置 這里說了相同的服務,不同環境下的配置。

那如果是 不同的微服務下相同的配置呢?

舉個例子,大家的注冊中心地址都是同一個,要把這個公共的配置項抽取到一個單獨的文件去管理。


實現

方式一 通過 shared-dataids 方式


方式二 通過 ext-config方式


配置文件優先級

我們看日志Nacos加載的順序

Located property source: CompositePropertySource {name='NACOS', propertySources=[ NacosPropertySource {name='artisan-config-center-dev.yml'}, 優先級最高 NacosPropertySource {name='artisan-config-center.yml'}, 次之 NacosPropertySource {name='artisan-config-center'}, 再次之 NacosPropertySource {name='common4.yml'}, 再次之 NacosPropertySource {name='common3.yml'}, 再次之 NacosPropertySource {name='common2.yml'}, 再次之 NacosPropertySource {name='common.yml'}]} 級別最低

artisan-config-center-dev.yml 優先級最高 ,依次排開。

舉個例子 假設 artisan-config-center-dev.yml 中存在配置項A, 則以artisan-config-center-dev.yml中的配置項A的值為準,如果artisan-config-center-dev.yml不存在,則互補。

總結一下 : 精準配置>不同環境的通用配置>不同工程的(ext-config)>不同工程(shared- dataids)

上述配置 加載的優先級

1)artisan-config-center-dev.yml 精準配置 2)artisan-config-center.yml 同工程不同環境的通用配置 3)ext-config: 不同工程 通用配置3.1):common4.yml3.2): common3.yml 4) shared-dataids 不同工程 通用配置4.1)common2.yml4.2)common1.yml

我們來看下完整的啟動日志

2022-02-04 18:00:46.500 INFO 16452 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$7254c629] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). ____ _ __ _ _/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/ ___)| |_)| | | | | || (_| | ) ) ) )' |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot :: (v2.1.3.RELEASE)2022-02-04 18:00:48.303 INFO 16452 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Loading nacos data, dataId: 'common.yml', group: 'DEFAULT_GROUP', data: spring:cloud:nacos:discovery: # 故意配置錯一個地址,用來驗證優先級 server-addr: 2.117.97.88:8848 2022-02-04 18:00:48.380 INFO 16452 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Loading nacos data, dataId: 'common2.yml', group: 'DEFAULT_GROUP', data: spring:cloud:nacos:discovery: server-addr: 1.117.97.88:8848 2022-02-04 18:00:48.483 INFO 16452 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Loading nacos data, dataId: 'common3.yml', group: 'DEFAULT_GROUP', data: server:port: 9999 2022-02-04 18:00:48.665 INFO 16452 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Loading nacos data, dataId: 'common4.yml', group: 'DEFAULT_GROUP', data: server:port: 10000 2022-02-04 18:00:48.761 WARN 16452 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[artisan-config-center] & group[DEFAULT_GROUP] 2022-02-04 18:00:48.857 INFO 16452 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Loading nacos data, dataId: 'artisan-config-center.yml', group: 'DEFAULT_GROUP', data: server: servlet:context-path: /configApp 2022-02-04 18:00:48.922 INFO 16452 --- [ main] c.a.c.n.c.NacosPropertySourceBuilder : Loading nacos data, dataId: 'artisan-config-center-dev.yml', group: 'DEFAULT_GROUP', data: server:port: 5678 # 是否走新業務邏輯的開關 isNewPath: false 2022-02-04 18:00:48.922 INFO 16452 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='NACOS', propertySources=[NacosPropertySource {name='artisan-config-center-dev.yml'}, NacosPropertySource {name='artisan-config-center.yml'}, NacosPropertySource {name='artisan-config-center'}, NacosPropertySource {name='common4.yml'}, NacosPropertySource {name='common3.yml'}, NacosPropertySource {name='common2.yml'}, NacosPropertySource {name='common.yml'}]} 2022-02-04 18:00:48.925 INFO 16452 --- [ main] com.artisan.ConfigCenterApplication : The following profiles are active: dev 2022-02-04 18:00:49.382 INFO 16452 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=c392b682-9e0b-366f-8375-9d3b5444358b 2022-02-04 18:00:49.404 INFO 16452 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$7254c629] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2022-02-04 18:00:49.625 INFO 16452 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 5678 (http) 2022-02-04 18:00:49.648 INFO 16452 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-02-04 18:00:49.649 INFO 16452 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.16] 2022-02-04 18:00:49.654 INFO 16452 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\Program Files (x86)\Java\jdk1.8.0_261\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:\Programs\Python\Python38\Scripts\;D:\Programs\Python\Python38\;D:\Program Files (x86)\Java\jdk1.8.0_261\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;D:\Program Files (x86)\Git\cmd;D:\Program Files (x86)\apache-maven-3.6.3\\bin;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\Program Files\python;C:\Program Files\python\Scripts;D:\BtSoft\panel\script;D:\Program Files\nodejs\;D:\Program Files (x86)\Python27;D:\Program Files (x86)\Java\jdk1.8.0_261\jre\bin;C:\Users\artisan\AppData\Local\Microsoft\WindowsApps;C:\Users\artisan\AppData\Roaming\npm;D:\Program Files (x86)\JetBrains\PyCharm 2020.1\bin;;D:\Program Files\VS Code\Microsoft VS Code\bin;.] 2022-02-04 18:00:49.742 INFO 16452 --- [ main] o.a.c.c.C.[.[localhost].[/configApp] : Initializing Spring embedded WebApplicationContext 2022-02-04 18:00:49.742 INFO 16452 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 805 ms 2022-02-04 18:00:49.818 WARN 16452 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources. 2022-02-04 18:00:49.819 INFO 16452 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath. 2022-02-04 18:00:49.821 WARN 16452 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources. 2022-02-04 18:00:49.822 INFO 16452 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath. 2022-02-04 18:00:49.983 INFO 16452 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2022-02-04 18:00:51.657 INFO 16452 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname 2022-02-04 18:00:51.683 INFO 16452 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 2022-02-04 18:00:53.265 INFO 16452 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname 2022-02-04 18:00:53.404 INFO 16452 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 5678 (http) with context path '/configApp' 2022-02-04 18:00:54.529 INFO 16452 --- [ main] c.a.c.n.registry.NacosServiceRegistry : nacos registry, DEFAULT_GROUP artisan-config-center 192.168.5.1:5678 register finished 2022-02-04 18:00:56.061 INFO 16452 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname 2022-02-04 18:00:56.064 INFO 16452 --- [ main] com.artisan.ConfigCenterApplication : Started ConfigCenterApplication in 12.183 seconds (JVM running for 13.171)

源碼

https://github.com/yangshangwei/SpringCloudAlibabMaster

總結

以上是生活随笔為你收集整理的Spring Cloud Alibaba - 19 Nacos Config配置中心加载不同微服务的通用配置的两种方式的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 精品免费囯产一区二区三区 | 深夜福利在线播放 | 欧美视频第二页 | 欧美中文字幕在线视频 | 午夜tv影院 | 丰满雪白极品少妇流白浆 | 老熟女毛茸茸浓毛 | 精品偷拍网| 超级黄色录像 | 最新色网站 | 欧美人与性囗牲恔配 | 国产精品扒开腿做爽爽爽男男 | 亚洲第一色图 | 亚洲激情图 | 国产精品一区二区三区在线 | 亲子乱对白乱都乱了 | 精品福利一区二区 | 精品少妇一区二区三区免费观 | 日韩精品无码一区二区三区久久久 | www色日本 | 超碰免费在线 | 老牛影视av一区二区在线观看 | 亚洲欧美另类综合 | 草久免费视频 | 亚洲一区电影 | 中文无码日韩欧 | 国产chinasex对白videos麻豆 | 久久免费视频一区二区 | 久久久久久网站 | 黄色片视频免费观看 | 激情一区二区三区 | 在线色网| 91久久综合亚洲鲁鲁五月天 | 中文字幕3区 | 喷水av| 国产欧美视频在线播放 | 青青自拍视频 | 国产精品成人在线 | 亚洲毛片在线播放 | 欧美日韩在线一区 | 久久6精品 | 免费小视频在线观看 | 特级西西444www大精品视频免费看 | 国产一区二区三区久久久 | 碰超在线 | 人与动物av | 懂色一区二区三区免费观看 | 国产成人宗合 | 精品毛片| av色哟哟| 福利影院av| 美国毛片av | 亚洲性视频在线 | 黄网站在线观 | 亚洲熟妇无码一区二区三区导航 | 日韩亚洲国产欧美 | 午夜性影院 | 久久在线精品视频 | 成人av动漫 | 最新国产精品视频 | 成人免费在线观看网站 | 亚洲少妇15p | 久久久久久久久久一区二区三区 | 久久精品天天中文字幕人妻 | 91精品国产高清一区二区三密臀 | 无遮挡毛片 | 91国产精品 | 亚洲精品www久久久久久 | 高清乱码免费 | 国产成人看片 | 欧美精品自拍 | 国产乱码精品1区2区3区 | 中字幕一区二区三区乱码 | 精品三级av| 777色| 欧美做爰全过程免费看 | 亚欧日韩 | 亚洲午夜精品久久久久久浪潮 | www.欧美在线观看 | 特种兵之深入敌后高清全集免费观看 | 色哟哟在线观看视频 | 国产精品老熟女一区二区 | 欧美高清性 | 中文字幕 日韩有码 | 伊人爱爱网 | 97caoporn| 久久影院午夜 | 777精品久无码人妻蜜桃 | 久久国产日韩 | 色综合天天综合网国产成人网 | 国产精品美女www爽爽爽视频 | 免费日韩一区二区 | 69av一区二区三区 | 波多野42部无码喷潮在线 | 久久久久麻豆v国产精华液好用吗 | 丝袜中文字幕 | 午夜在线观看影院 | 国产成人精品片 | 激情综合啪啪 |