配置文件中的nacos配置,discovery和config配置项
版本:
<spring.boot.version>2.3.2.RELEASE</spring.boot.version>
<spring.cloud.version>Hoxton.SR9</spring.cloud.version>
<com.alibaba.cloud>2.2.6.RELEASE</com.alibaba.cloud>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
- discovery: 配置指定了服务的注册命名空间,可以单独配置
- config:指定服务获取nacos配置的空间,只配置config时,namespace配置无效,命名空间都指向public,只有同时配置discovery,并指定同样的namespace才会生效
spring:
application:
name: server
cloud:
nacos:
#指定服务的注册空间
discovery:
server-addr: 127.0.0.1:8848
namespace: f0594770-d535-47c4-87b8-b2d82e318473
#指定服务获取配置的空间
config:
server-addr: 127.0.0.1:8848
namespace: f0594770-d535-47c4-87b8-b2d82e318473
extension-configs[o]:
data-id: test.yaml
group: test
refresh: true