1、application.properties配置dubbo信息
### dubbo 配置 ### #设置当前服务在zk当中的应用名称,全局唯一 spring.dubbo.application.name=paoyou-gm # 设置zk的服务端口 # spring.dubbo.registry.address=zookeeper://127.0.0.1:2180 # 设置当前项目当中使用dubbo注解的包路径# spring.dubbo.scan=com.paoyou.service.center spring.dubbo.consumer.check = true ### protocal配置 ### paoyou.dubbo.protocol.name = dubbo paoyou.dubbo.protocol.port = 29003 paoyou.dubbo.protocol.theads = 50 ### provider配置 ### paoyou.dubbo.provider.timeout = 10000 paoyou.dubbo.provider.retries = 0 paoyou.dubbo.provider.version = 1.0.0 paoyou.dubbo.provider.group = gm
2、服务提供方使用@Service注解暴露服务
@Service( version = "${dubbo.application.version}", application = "${dubbo.application.id}", protocol = "${dubbo.protocol.id}", registry = "${dubbo.registry.id}") public class BaseFacade { } public class BguserFacadeImpl extends BaseFacade implements BguserFacade { ... }
3、服务消费方使用@Reference注解来引用服务
@Reference(version = "${dubbo.application.version}", application = "${dubbo.application.id}") private BguserFacade bguserFacade;