搭建基于springboot2.0的dubbo服务
原来用过一段时间的dubbo,但是是在springmvc的基础上集成的,现在开始使用springboot2.0,所以想在此基础上集成dubbo的功能,Dubbo原理等就不在此进行深入的说明。
1、工程搭建
1.1、创建一个父工程demo-parent
1.2、创建api工程demo-dubbo-api
在刚刚创建的工程上右键New->Project->maven->Maven Module,Name设置为demo-dubbo-api,和父模块的创建步骤一致,一路next。
1.3、创建provider工程demo-dubbo-provider
同上
1.4、创建consumer工程demo-dubbo-consumer
同上
2、dubbo配置
2.1 pom设置
springboot相关的配置不在此进行详细的说明,具体的自行百度或查看官网文档。
2.2 创建接口
在demo-dubbo-api工程中创建一个接口DemoService

2.3 provider设置
在demo-dubbo-provider工程的resource文件下创建dubbo-provider.xml文件

2.4 consumer设置
在demo-dubbo-consumer工程的resource文件下创建dubbo-consumer.xml文件

3、实现
3.1 servie实现类DemoServiceImpl
3.2、创建调用的类
在demo-dubbo-consumer中创建一个controller,如DemoController

3.3、创建provider启动类ProviderApplication

3.4、创建consumer启动类ConsumerApplication

4、启动
分别启动我们的demo-dubbo-provider和demo-dubbo-consumer
5、访问
在浏览器中访问接口http://127.0.0.1:8080/say?name=zhang

也参考了很多网上的文章,最后还是根据官网的说明一步一步的进行配置成功,在此做个简单的记录。