Dubbo(一):dubbo-spring-boot-starter
dubbo-spring-boot-starter
Dubbo Spring Boot Starter。也可以关注dubbo官方的dubbo-spring-boot-project
支持jdk版本为1.6或者1.6+
(在修改源码前,请导入googlestyle-java.xml以保证一致的代码格式)
如何发布dubbo服务
- 添加依赖:
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
- 在application.properties添加dubbo的相关配置信息,样例配置如下:
spring.application.name=dubbo-spring-boot-starter
spring.dubbo.server=true
spring.dubbo.registry=N/A
注:这个配置只针对服务提供端,消费端不用指定协议,它自己会根据服务端的地址信息和@Reference注解去解析协议
- 接下来在Spring Boot Application的上添加
@EnableDubboConfiguration,表示要开启dubbo功能. (dubbo provider服务可以使用或者不使用web容器)
@SpringBootApplication
@EnableDubboConfiguration
public class DubboProviderLauncher {
//...
}
- 编写你的dubbo服务,只需要添加要发布的服务实现上添加
@Service(import com.alibaba.dubbo.config.annotation.Service)注解,其中interfaceClass是要发布服务的接口.
@Service(interfaceClass = IHelloService.class)
@Component
public class HelloServiceImpl implements IHelloService {
//...
}
- 启动你的Spring Boot应用,观察控制台,可以看到dubbo启动相关信息.
如何消费Dubbo服务
- 添加依赖:
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
- 在application.properties添加dubbo的相关配置信息,样例配置如下:
spring.application.name=dubbo-spring-boot-starter
- 开启
@EnableDubboConfiguration
@SpringBootApplication
@EnableDubboConfiguration
public class DubboConsumerLauncher {
//...
}
- 通过
@Reference注入需要使用的interface.
@Component
public class HelloConsumer {
@Reference(url = "dubbo://127.0.0.1:20880")
private IHelloService iHelloService;
}
参考文档
- dubbo: http://dubbo.io
- spring-boot: http://projects.spring.io/spring-boot
- dubbo-spring-boot-project: https://github.com/dubbo/dubbo-spring-boot-project
Links:
本文由低调小熊猫一文多发操作发布! 欢迎关注公众号:低调小熊猫
Dubbo(一):dubbo-spring-boot-starter的更多相关文章
- Spring Boot Starter 介绍
http://www.baeldung.com/spring-boot-starters 作者:baeldung 译者:http://oopsguy.com 1.概述 依赖管理是任何复杂项目的关键部分 ...
- spring -boot s-tarter 详解
Starter POMs是可以包含到应用中的一个方便的依赖关系描述符集合.你可以获取所有Spring及相关技术的一站式服务,而不需要翻阅示例代码,拷贝粘贴大量的依赖描述符.例如,如果你想使用Sprin ...
- Spring Boot (一): Spring Boot starter自定义
前些日子在公司接触了spring boot和spring cloud,有感于其大大简化了spring的配置过程,十分方便使用者快速构建项目,而且拥有丰富的starter供开发者使用.但是由于其自动化配 ...
- SpringBoot 之Spring Boot Starter依赖包及作用
Spring Boot 之Spring Boot Starter依赖包及作用 spring-boot-starter 这是Spring Boot的核心启动器,包含了自动配置.日志和YAML. spri ...
- Spring boot starter pom的依赖关系说明
Spring Boot 通过starter依赖为项目的依赖管理提供帮助.starter依赖起始就是特殊的maven依赖,利用了传递依赖解析,把常用库聚合在一起,组成了几个为特定功能而定制的依赖. sp ...
- Spring Boot Starter列表
转自:http://blog.sina.com.cn/s/blog_798f713f0102wiy5.html Spring Boot Starter 基本的一共有43种,具体如下: 1)spring ...
- 创建自己的Spring Boot Starter
抽取通用模块作为项目的一个spring boot starter.可参照mybatis的写法. IDEA创建Empty Project并添加如下2个module,一个基本maven模块,另一个引入sp ...
- 自己写spring boot starter
自己写spring boot starter 学习了:<spring boot实战>汪云飞著 6.5.4节 pom.xml <project xmlns="http://m ...
- 自定义的Spring Boot starter如何设置自动配置注解
本文首发于个人网站: 在Spring Boot实战之定制自己的starter一文最后提到,触发Spring Boot的配置过程有两种方法: spring.factories:由Spring Boot触 ...
- 手把手教你定制标准Spring Boot starter,真的很清晰
写在前面 我们每次构建一个 Spring 应用程序时,我们都不希望从头开始实现具有「横切关注点」的内容:相反,我们希望一次性实现这些功能,并根据需要将它们包含到任何我们要构建的应用程序中 横切关注点 ...
随机推荐
- FusionSphere产品功能
华为Fusion产品 FusionSphere解决方案的三种场景 服务器虚拟化 NFVI:运营商基于openstack kvm协议的解决方案 云数据中心 FusionSphere服务器虚拟化解决方案 ...
- flask的request如何获取参数
1.request.form.get("key", type=str, default=None) 获取表单数据 2.request.args.get("key" ...
- v8::V8::InitializeICU();
InitializeICU v8引擎 学习 ...
- 201871010101-陈来弟《面向对象程序设计(Java)》第十二周学习总结
201871010101-陈来弟<面向对象程序设计(Java)>第十二周学习总结 实验十 集合与GUI初步 实验时间 2019-11-14 第一部分 理论部分 1.(1) 用户界面 ...
- Maven 中 dependencyManagement 元素,知识点
Maven 提供的 dependencyManagement 元素既能让子模块继承到父模块的依赖配置,又能保证子模块依赖使用的灵活性.在 dependencyManagement 元素下的依赖声明不会 ...
- pip安装指定版本的程序的命令
pip安装指定版本的程序的命令 pip install -i https://pypi.douban.com/simple/ django==1.10.3 或者 pip install django= ...
- Ultimate Chicken Horse GameProject第二次迭代成果文档
基于上一次的迭代中的数据结构我们补充了UML图.用例图及状态图. 用例图: 选择游戏地图:玩家可以在本地游戏界面将角色移动到地图门口并按下E进入地图. 进行游戏用例: 选择并摆放道 ...
- [LeetCode] 314. Binary Tree Vertical Order Traversal 二叉树的竖直遍历
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bott ...
- 第09组 Beta冲刺(1/5)
队名:观光队 链接 组长博客 作业博客 组员实践情况 王耀鑫 过去两天完成了哪些任务 文字/口头描述 任务分配 展示GitHub当日代码/文档签入记录 接下来的计划 完成短租车,页面美化 还剩下哪些任 ...
- GreenPlum 大数据平台--集群恢复
一,问题描述 :::: gpinitstandby:greenplum01:gpadmin-[ERROR]:-Cannot use -n option when standby master has ...