Spring Cloud 整合Nacos服务注册发现功能详细图文教程

 

 

 

 

 

 

 在service模块加入以下组件:

 

<!--   nacos 服务注册发现依赖组件     -->

       <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
            <!-- 服务间通讯组件使用feign并用okhttp优化feign  -->
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
        </dependency>



 

 

这就完了吗?当然光这个配置是不行的,记得以前我们使用eureka作为服务注册发现中心是如何启用的吗?通过@EnableEurekaClient 注解,事实上我们知道@EnableDiscoveryClient是个更通用的注解。因为我们启用了feign,所以我们要加上feign的启用注解@EnableFeignClients 。
我们在需要以上功能的Spring Boot 应用上增加相应的注解如下:

 

 

https://felord.cn/spring-cloud-nacos-discovery.html

 

posted @ 2020-12-24 14:43  小蚊子大人KN  阅读(247)  评论(0编辑  收藏  举报