alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
30.36k stars 12.86k forks source link

【疑问】nacos-config 包下的DynamicDataSource类 为什么要添加@Component注解 #8532

Closed wangsj1018 closed 2 years ago

wangsj1018 commented 2 years ago

com.alibaba.nacos.config.server.service.datasource.DynamicDataSource 我认为这是一个单例类去获取数据源,但是发现没有构造私有化,增加了一个@Component注入到spring容器了,但是我看到这个类的使用都是DynamicDataSource .getInstance().getDataSource();
spring容器中获取的bean 和 DynamicDataSource .getInstance() 并不是同一个对象呀。

image

KomachiSion commented 2 years ago

@shiyiyue1102 Component is submited by you, can you answer this problem?

shiyiyue1102 commented 2 years ago

DynamicDataSource

it may be a mistake, the annotation can be removed.

Aldohomzlo commented 2 years ago

Excelente