1、创建mave项目:
2、修改pom.xml文件:
4.0.0 com.ym springbootdubbo pom 1.0-SNAPSHOT service serviceImpl testweb org.springframework.boot spring-boot-starter-parent 1.5.9.RELEASE UTF-8 1.8 1.8 junit junit 3.8.2 org.springframework.boot spring-boot-starter-web com.alibaba.boot dubbo-spring-boot-starter 0.1.0 org.springframework.boot spring-boot-starter-actuator ch.qos.logback logback-core ch.qos.logback logback-classic com.101tec zkclient 0.10 org.eclipse.jetty jetty-maven-plugin 9.4.6.v20170531 maven-clean-plugin 3.0.0 maven-resources-plugin 3.0.2 maven-compiler-plugin 3.7.0 maven-surefire-plugin 2.20.1 maven-jar-plugin 3.0.2 maven-install-plugin 2.5.2 maven-deploy-plugin 2.8.2
3、创建远程接口定义模块:
4、创建接口:
5、创建接口实现模块:
6、springboot整合application.yml:
dubbo-provider-app 9090 com.ym.service dubbo-provider dubbo-provider duboo dubbo 12345 server my-reg zookeeper://192.168.1.224:2181 true 9091 load,threadpool memory
7、实现接口:
com.ym.service.impl; com.alibaba.dubbo.config.annotation.; com.ym.service.TestService; (version = ,application = ,protocol = ,registry = ) TestServiceImpl TestService { String getData(String name) { + name; } }
8、创建启动程序:
ym; org.springframework.boot.SpringApplication; org.springframework.boot.autoconfigure.; StartSpringBootMain { main(String[] args) { SpringApplication.(StartSpringBootMain.); } }
观察dubbo控制台:
9、创建消费端:
10、整合springboot和dubbo(application.yml):
dubbo-consumer-app 8080 dubbo-consumer dubbo-consumer duboo dubbo 54321 my-reg zookeeper://192.168.1.224:2181
11、创建controller程序,引用远程接口:
com.ym.controller; com.alibaba.dubbo.config.annotation.; com.ym.service.TestService; org.springframework.web.bind.annotation.; org.springframework.web.bind.annotation.; org.springframework.web.bind.annotation.; () TestController { (version = , application = ) TestService ; () String getData(() String name) { .getData(name); } }
12、创建启动程序,并启动项目:
com.ym; org.springframework.boot.SpringApplication; org.springframework.boot.autoconfigure.; (scanBasePackages = ) StartSpringBootMain { main(String[] args) { SpringApplication.(StartSpringBootMain.); } }
13、观察dubbo控制台: