spring-cloud-alibaba Mistake load @Bean when use config dubbo.registries

oxiaedzo  于 3个月前  发布在  Spring
关注(0)|答案(1)|浏览(125)

我们鼓励使用英文,如果不能直接使用,可以使用翻译软件,您仍旧可以保留中文原文。
We recommend using English. If you are non-native English speaker, you can use the translation software.

Which Component
dubbo

Describe the bug
When we use config in *.yaml like this:

dubbo:
  registries:
    address: spring-cloud://localhost

the @bean method in DubboServiceRegistrationAutoConfiguration class

@Bean
	@Conditional({ MissingSpringCloudRegistryConfigPropertyCondition.class })
	public RegistryConfig defaultSpringCloudRegistryConfig() {
		return new RegistryConfig(ADDRESS, PROTOCOL);
	}

should not be load

But in fact it is loaded.

To Reproduce
Just config like above and debug the app.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.
e.g. MacOS 、Java8 、 Version 0.2.1.RELEASE

0s7z1bwu

0s7z1bwu1#

import org.apache.dubbo.config.RegistryConfig;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@configuration(proxyBeanMethods = false)
@ConditionalOnClass(RegistryConfig.class)
@ConditionalOnDubboConfigEnabled
public class DubboServiceRegistrationAutoConfiguration {

@Bean
@Conditional({ MissingSpringCloudRegistryConfigPropertyCondition.class })
@ConditionalOnMissingBean // Add this annotation
public RegistryConfig defaultSpringCloudRegistryConfig() {
    return new RegistryConfig(ADDRESS, PROTOCOL);
}

// Other configuration methods

}

相关问题