赞
踩
值得注意的是:nacos config的配置必须配置在bootstrap.properties文件中,不然无法加载
spring.profiles.active=prod spring.application.name=order-service spring.cloud.nacos.discovery.server-addr=localhost:8848 spring.cloud.nacos.config.server-addr=localhost:8848 #谁在越后面有优先级越高 spring.cloud.nacos.config.shared-configs[0]=common1.properties spring.cloud.nacos.config.shared-configs[1]=common2.properties
引入配置
- <dependency>
- <groupId>com.alibaba.cloud</groupId>
- <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
- </dependency>
nacos上配置如下:
启动工程时候会出现下面
2021-05-13 21:42:09.962 INFO 21000 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source:
[
BootstrapPropertySource {name='bootstrapProperties-order-service-prod.properties,DEFAULT_GROUP'},//nacos config 服务器上,最完全匹配
BootstrapPropertySource {name='bootstrapProperties-order-service.properties,DEFAULT_GROUP'},//nacos config ,默认配置
BootstrapPropertySource {name='bootstrapProperties-order-service,DEFAULT_GROUP'},//本地匹配,默认配置
BootstrapPropertySource {name='bootstrapProperties-common2.properties,DEFAULT_GROUP'},//nacos config,通用配置
BootstrapPropertySource {name='bootstrapProperties-common1.properties,DEFAULT_GROUP'}//nacos config ,通用配置
]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。