alibaba/spring-cloud-alibaba

Whether contain spring-cloud-loadbalancer dependency in nacos-discovery module

Open

#3,115 opened on Jan 28, 2023

View on GitHub
 (2 comments) (1 reaction) (0 assignees)Java (29,106 stars) (8,513 forks)batch import
good first issuekind/discussion

Description

Which Component eg. Nacos Discovery

Describe what problem you have encountered In relevant versions of spring-cloud-starter-alibaba-nacos-discovery from branch of 2.2.x, we add following dependency in it.

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>

For outside user, they just need to add spring-cloud-starter-alibaba-nacos-discovery, then can call downstream service directly. But in relevant versions of spring-cloud-starter-alibaba-nacos-discovery from branch of 2021.x, Spring Cloud remove Ribbon from 2020.0.0, we did some adjustments, we use following loadbalancer module replacing Ribbon:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-loadbalancer</artifactId>
    <optional>true</optional>
</dependency>

This piece is consistent with spring-cloud-netflix-eureka-client. Because of the optional attribute set to true, users need to add spring-cloud-starter-alibaba-nacos-discovery in addition to adding spring-cloud-loadbalancer to new applications manually. Otherwise the application cannot normally consume services. Setting the optional attribute to true in spring-cloud-starter-alibaba-nacos-discovery has the following benefits:

  1. Reduce the size of the spring-cloud-starter-alibaba-nacos-discovery dependency report. If the application is not a consumer, it does not need to add redundant spring-cloud-loadbalancer dependencies.
  2. Let the user clearly know what load balancing component he/she is using.

shortcoming:

  1. The threshold for application construction has been raised. For beginners of Spring Cloud, it is easy to forget the spring-cloud-loadbalancer dependency for the first time.

Some users suggested that the community remove optional attributes from subsequent versions in branch of 2021.x, so that they no longer need to manually add spring-cloud-loadbalancer dependencies. What do you think?

Contributor guide

Whether contain spring-cloud-loadbalancer dependency in nacos-discovery module · alibaba/spring-cloud-alibaba#3115 | Good First Issue