Nacos入门
作者:互联网
1.在父项目中引入SpringCloudAlibaba依赖
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring.cloud-version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>2.2.5.RELEASE</version> <scope>import</scope> <type>pom</type> </dependency> </dependencies> </dependencyManagement>
2.在服务提供项目中新增Nacos服务发现依赖及配置
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency>
spring: application: name: consumer cloud: nacos: server-addr: localhost:8848
即可将服务注册到Nacos注册中心。
nacos服务的调用方式与Eureka的调用方式相同,都使用RestTemplate调用,同样需要在RestTemplate 注入方法上添加负载均衡注解
nacos服务分级存储模型:1.服务 2.集群 3.实例
TRANSLATE with x English TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back
标签:入门,spring,nacos,Nacos,alibaba,com,cloud 来源: https://www.cnblogs.com/myvoice/p/16606965.html