启动时检查
Dubbo缺省会在启动时检查依赖的服务是否可用,不可用时会抛出异常,阻止Spring初始化完成,以便上线时,能及早发现问题,默认check=true。
如果你的Spring容器是懒加载的,或者通过API编程延迟引用服务,请关闭check,否则服务临时不可用时,会抛出异常,拿到null引用,如果check=false,总是会返回引用,当服务恢复时,能自动连上。
可以通过check=”false”关闭检查,比如,测试时,有些服务不关心,或者出现了循环依赖,必须有一方先启动。
1 关闭某个服务的启动检查
<dubbo:reference interface="com.xxx.xxxService" check="false" />
2.关闭所有服务的启动时检查:(没有提供者时报错)
<dubbo:consumer check="false" />
3.关闭注册中心启动时检查
<dubbo:registry check="false" />
4.用dubbo.properties配置
dubbo.properties
dubbo.reference.com.foo.BarService.check=false
dubbo.reference.check=false
dubbo.consumer.check=false
dubbo.registry.check=false