springboot跨服务调用_springboot远程调用dubbo服务接口

1.首先idea新建一个springboot项目,这里简单介绍下:

e94921b619afc6a41fe22283b4af98bf.png
2c6b826803608ad162bf14a800b3657a.png
22e36d90a8536962fc0e27bfac4415a7.png

2.在springboot启动类上加入注解

@ImportResource(locations = {"classpath*:dubbo_config/*.xml"})

locations 为你的dubbo相关配置文件路径

3.pom文件配置

<?xml version="1.0" encoding="UTF-8"?>4.0.0org.springframework.boot spring-boot-starter-parent 2.1.9.RELEASEcom.example demo 0.0.1-SNAPSHOTdemoDemo project for Spring Boot1.8org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test testcom.** ****-api 1.2.4com.** ****-client 1.2.4io.dubbo.springboot spring-boot-starter-dubbo RELEASEorg.apache.zookeeper zookeeper 3.4.6org.slf4j slf4j-log4j12 log4j log4j org.springframework.boot spring-boot-maven-plugin 

4.application name配置

1b41e8a1f9e4968006b61543e62d9b49.png
<?xml version="1.0" encoding="UTF-8"?>

5.controller调用

@Controllerpublic class MemberIndexController { @Autowired private DemoService demoService; /** * @RestController 相当于@Controller + @ResponseBody * 第一种启动方式:@EnableAutoConfiguration 注解作用:扫描范围:默认当前类里面, * SpringApplication.run(MemberController.class); * 第二种加上扫描范围 */ @RequestMapping("/memberIndex") @ResponseBody public String memberIndex() { demoService.sayHello("SpringBoot Dubbo test"); System.out.println("memberIndex"); return "springboot成功+memberIndex"; }}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值