项目使用dubbo时候,默认配置是需要先启动服务器提供者后再启动服务消费着,不然会报错。
直接上代码:
@Bean
public ConsumerConfig consumerConfig() {
ConsumerConfig consumerConfig = new ConsumerConfig();
consumerConfig.setCheck(false);
consumerConfig.setTimeout(20000);
return consumerConfig;
}
自己做法就是把配置到核心工程模块里,其他模块引用即可。
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.alibaba.dubbo.config.ConsumerConfig;
@Configuration
public class DubboConfig {
/**
* 消费者配置不主动监督zookeeper服务
*
* @return
*/
@Bean
public ConsumerConfig consumerConfig() {
ConsumerConfig consumerConfig = new ConsumerConfig();
consumerConfig.setCheck(false);
consumerConfig.setTimeout(40000);
return consumerConfig;
}
}