Dubbo基础学习配置
Dubbo 配置文件
- 消费方配置
check
1 | <dubbo:consumer timeout="3000" check="false"/> |
check = false 防止启动报错 没有提供者会自动生成代理(测试环境使用)
check = true 没有提供者直接报错(正式环境使用)
cluster 负载策略(常用的两种)
1 | <dubbo:reference id="productService" interface="com.tupelo.service.ProductService" cluster="failover" /> |
泛化调用 当A项目没有得到B项目的接口描述 但是还是想调用B项目的接口
1 配置dubbo引入,设置generic = true1
<dubbo:reference id="otherService" interface="com.enjoy.service.OtherService" generic="true" />
2 从IOC容器中取出代理对象,转为泛型接口对象 通过$invoke方法调用目标方法(传入方法名/参数类型/参数值)
1 | public String other(HttpServletRequest request, HttpServletResponse response) { |