dubbo是一个分布式的服务架构,可直接用于生产环境作为SOA服务框架。
官网首页:http://dubbo.io/
当当网的扩展版本dubbox :https://github.com/dangdangdotcom/dubbox
京东的扩展版本jd-hydra: http://www.oschina.NET/p/jd-hydra
Dubbox在maven中央仓库并没有对应的依赖,所以我们需要自己动手将其发布到我们的本地仓库来使用。
使用git从码云上把dubbox的代码clone下来,
执行Maven命令把工程安装到本地仓库
命令:clean install -Dmaven.test.skip
- pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.4.RELEASE</version> </parent> <artifactId>spring-boot-starter-dubbo</artifactId> <version>1.4.4.RELEASE</version> <name>Spring Boot Dubbo Rpc</name> <description>Spring Boot Dubbo Rpc</description> <url>http://projects.spring.io/spring-boot/</url> <organization> <name>Pivotal Software, Inc.</name> <url>http://www.spring.io</url> </organization> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>1.7</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>2.8.5-SNAPSHOT</version> <exclusions> <exclusion> <artifactId>spring</artifactId> <groupId>org.springframework</groupId> </exclusion> </exclusions> </dependency> <!-- zookeeper 客户端 --> <dependency> <groupId>com.github.sgroschupf</groupId> <artifactId>zkclient</artifactId> <version>0.1</version> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.4.4.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <artifactId>maven-source-plugin</artifactId> <configuration> <attach>true</attach> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
-
zookeeper注册中心
我们使用zookeeper作为dubbo的注册中心。
这里使用的zookeeper注册中心地址是:192.168.37.161:2181
修改hosts,配置注册中心的域名是zookeeper.taotao.com -
搭建项目
taotao-parent作为所有工程的父工程
taotao- interface作为提供pojo和抽取服务接口的
taotao-provider作为服务提供者
taotao-consumer作为服务消费者