Spring Cloud Alibaba 之 Nacos Discovery服务注册发现(三)
一、Nacos Discovery服务注册发现
1、服务提供者
1、 创建一个springboot模块springcloud-alibaba-1-nacos-discovery-provider;
2、 添加spring-cloud-starter-alibaba-nacos-discovery等依赖;
(1)通过添加一个starter依赖:spring-cloud-starter-alibaba-nacos-discovery它通过自动配置、注解以及Spring Boot 编程模型与Nacos无缝集成,实现服务注册与发现
<!--spring-cloud-alibaba nacos服务注册/发现的依赖-->
<!--格式: spring-cloud-starter-[开源组织机构名字]-[项目模块名字]-->
<!--spring-cloud-starter-alibaba-sentinel-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!--spring-boot-starter-actuator-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
(2)Spring Cloud Alibaba 和 Spring Cloud,Spring Boot对应版本
在该工程的 pom.xml 中,我们通过 dependencyManagement 对 Spring Cloud Alibaba 的版本信息进行管理,该工程下的各个子模块在引入 Spring Cloud Alibaba 的各个组件时就不要单独指定版本号了