内容简介:消费者模块的配置源码下载地址:链接:
消费者模块的配置
-
消费者consume中pom.xml的配置 ,
引入接口和spring-boot-starter-web 是指这是一个web模块 spring-boot-starter-web如果用2.1.5.RELEASE 会报错,先用1.5.3<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>1.5.3.RELEASE</version> </dependency> <dependency> <groupId>com.hcb</groupId> <artifactId>dubboapi</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
-
建立配置文件 和provider一样,名字换成consumer就可以
spring.dubbo.appname=dubboconsumer spring.dubbo.registry=zookeeper://192.168.159.131:2181
-
建立启动类
package com.hcb; import com.alibaba.dubbo.spring.boot.annotation.EnableDubboConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import java.util.concurrent.CountDownLatch; @SpringBootApplication @EnableDubboConfiguration public class Consumer { public static void main(String[] args) { SpringApplication.run(Consumer.class,args); } }
-
建立controll类实现接口
package com.hcb; import com.alibaba.dubbo.config.annotation.Reference; import com.hcb.Service.IHelloService; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/hello") public class HelloController { @Reference IHelloService ihelloService; @RequestMapping public String hello(@RequestParam String name){ return ihelloService.SayHello(name); } }
-
启动消费者
- 测试
浏览器中输入 http://localhost:8080/hello?name=%E6%A1%82%E6%9E%97
正确显示出来
源码下载地址:
链接: https://pan.baidu.com/s/1WO2BQnsmIxP04mWNZin93A
提取码:5h0w
以上所述就是小编给大家介绍的《dubbo如何连接zookeepr(二)》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- tcp 长连接与短连接
- 没有 HTTP 连接池,空谈什么持久连接
- Linux中软连接和硬连接的区别
- sql – 哪个更好..左外连接还是右外连接?
- 连接池中的连接失效的几种处理方案
- 解决golang使用elastic连接elasticsearch时自动转换连接地址
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Ajax Design Patterns
Michael Mahemoff / O'Reilly Media / 2006-06-29 / USD 44.99
Ajax, or Asynchronous JavaScript and XML, exploded onto the scene in the spring of 2005 and remains the hottest story among web developers. With its rich combination of technologies, Ajax provides a s......一起来看看 《Ajax Design Patterns》 这本书的介绍吧!
HTML 编码/解码
HTML 编码/解码
Base64 编码/解码
Base64 编码/解码