alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.38k stars 8.16k forks source link

bug: `spring.cloud.discovery.enabled` properties is invalid. #3679

Closed yuluo-yx closed 1 month ago

yuluo-yx commented 1 month ago

Bgc

When developing with sca, if the service instance does not need to be registered with nacos, it can be configured with spring.cloud.discovery.enabled=false:

lQLPJwNaaU-IiDHMts0C87Bj1oc69JwybgYAaRo_0yQA_755_182

But this configuration is invalid! and causes the following error:

1712540425113_F30B2A38-6ACF-49f1-BECE-3B6596678B91

more info see: https://github.com/alibaba/spring-cloud-alibaba/issues/3675

Action

Check the nacos-discovery auto-assembly feature to resolve this issue.


背景

在使用 sca 进行开发时,如果服务实例不需要注册到 nacos,可以通过 spring.cloud.discovery.enabled=false 配置:

lQLPJwNaaU-IiDHMts0C87Bj1oc69JwybgYAaRo_0yQA_755_182

但是此配置无效!并会引起如下报错:

1712540425113_F30B2A38-6ACF-49f1-BECE-3B6596678B91

Action

检查 nacos-discovery 自动装配功能以解决此问题。

more info see: https://github.com/alibaba/spring-cloud-alibaba/issues/3675

cxhello commented 1 month ago

spring.cloud.discovery.enabled and spring.cloud.nacos.discovery.enabled I'm also confused about this. Do the two configurations have to be set to the same value?

yuluo-yx commented 1 month ago

`spring.cloud.discovery.enabled and spring.cloud.nacos.discovery.enabled I'm also confused about this. Do the two configurations have to be set to the same value?

unnecessary. Their relationship is that nacos is the implementation of sc service discovery and registration, and sc's standard

yuluo-yx commented 1 month ago

For this scenario, it shouldn't be bug.

The scenario is described as follows:

a consumer is not registered to nacos, but is able to invoke a service provider in the registry.

For the spring.cloud.discovery.enabled property, it defines a set of auto-assembly configurations for service discovery in the service. Like the spring.cloud.nacos.discovery.registry-enabled property, when set to false, it disables the loading of all configuration beans related to service discovery, and calls to the registry service cannot be completed.

The workaround is to use spring.cloud.service-registry.auto-registration.enabled or spring.cloud.nacos.discovery.register-enabled to disable the service registration and to be able to invoke the provider service.

cc @ruansheng8 @chickenlj