如果是dubbo配置文件的方式:
<dubbo:reference check="false"/>
reference标签添加 check="false" 这样就可以成功构造消费者对象,如果这时服务者没有启动,每次消费者调用服务者对象的时候,会提示没有对应的服务端;等到服务者启动的时候,就可以调用成功。
java config的方式:
直接上代码:
@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.se