SpringBoot整合Dubbo
一、导入依赖
二、生产者provider
(1)目录展示
(2)配置文件application.properties
(3)DoSomeService接口
package com.zn.service; public interface DoSomeService { public String sayHi(); }
(4)DoSomeServiceImpl实现类
package com.zn.service.impl; import com.alibaba.dubbo.config.annotation.Service; import com.zn.service.DoSomeService; import org.springframework.stereotype.Component; @Service(interfaceClass = DoSomeService.class) @Component public class DoSomeServiceImpl implements DoSomeService{ @Override public String sayHi() { System.out.println("生产者生产的IDoSomeService服务,中的sayHi方法"); return "SpringBoot Dubbo"; } }
(5)测试类StartDubbo
四、消费者consumer
(1)目录展示
(2)配置文件application.properties
(3)DoSomeService接口
package com.zn.service; public interface DoSomeService { public String sayHi(); }
(4)DubboController
package com.zn.controller; import com.alibaba.dubbo.config.annotation.Reference; import com.zn.service.DoSomeService; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class DubboController { @Reference private DoSomeService doSomeService; @RequestMapping("/dubbo") public String dubbo(){ String returnValue = doSomeService.sayHi(); return returnValue; } }
(5)测试类
五、效果展示
相关推荐
ATenhong 2020-10-15
supperme 2020-09-08
doctorvian 2020-08-02
aNian 2020-08-01
kongjunlongaa 2020-06-29
Fightingxr 2020-06-26
whileinsist 2020-06-24
doctorvian 2020-06-16
XuNeely 2020-06-16
wangyangsoftware 2020-06-16
大步流星 2020-06-16
aNian 2020-06-16
gaoyongstone 2020-06-16
MartellJenkins 2020-06-11
范群松 2020-06-11
Fightingxr 2020-06-08
XuNeely 2020-06-07
大步流星 2020-06-05