springboot集成dubbo
2018-11-26 14:55:39 星期一
1.引入dubbo和zookeeper的相关依赖
<!--dubbo-->
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>0.2.0</version>
</dependency>
<!--zookeeper-->
<!-- https://mvnrepository.com/artifact/com.github.sgroschupf/zkclient -->
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>0.1</version>
</dependency>
2.配置dubbo扫描包和注册中心地址
dubbo.application.name=provide-ticket
dubbo.registry.address=zookeeper://**.**.**.**:2181
dubbo.scan.base-packages=com.yhb.provideticket.service
3.用@Service(使用的是dubbo中的)发布服务
@Component //加入spring容器中去
@Service //将此作为dubbo服务发布出去
public class TicketServiceImpl implements TicketService{
public String getTicket() {
return "155";
}
}

浙公网安备 33010602011771号