Nacos环境隔离-namesapce
Nacos从服务存储和数据存储的最外层都是namespace,用于最外层隔离
每个Namespace都有一个唯一id
不同namespace下的服务不可见
namespace默认为public(保留空间)
在控制面板新建一个dev的namespace
在服务列表中可以看到两个命名空间
可以在配置文件中指定namespace
将命名空间ID写入进去
spring:
datasource:
url: jdbc:mysql://localhost:3306/cloud-order?useSSL=false
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
application:
name: orderservice
cloud:
nacos:
discovery:
server-addr: localhost:8848
cluster-name: HZ
namespace: 26339b4d-03f7-4234-8096-0da53d598bdd
此时访问服务,则提示无法访问
[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: No instances available for userservice] with root cause