1.Dubbo教程
转自:https://blog.csdn.net/hellozpc/article/details/78575773
2. 什么是dubbo
2.1. 简介
DUBBO是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,是阿里巴巴SOA服务化治理方案的核心框架,每天为2,000+个服务提供3,000,000,000+次访问量支持,并被广泛应用于阿里巴巴集团的各成员站点。
Dubbo是Alibaba开源的分布式服务框架,它最大的特点是按照分层的方式来架构,使用这种方式可以使各个层之间解耦合(或者最大限度地松耦合)。从服务模型的角度来看,Dubbo采用的是一种非常简单的模型,要么是提供方提供服务,要么是消费方消费服务,所以基于这一点可以抽象出服务提供方(Provider)和服务消费方(Consumer)两个角色。Dubbo框架使得使用者可以像调用本地方法一样调用远程方法,而这一切只需要简单的配置。Dubbo完全兼容Spring配置方式注入,未来也会与Spring boot无缝整合。
开发团队:
2.2. RPC
2.3. 官网
2.4. 版本说明
2017年9月份,沉寂了5年之久的Dubbo重新得到维护!
本教程基于2.5.7版本
2.5. 下载
Dubbo源码托管于github,并且将jar包发布到maven的中央仓库,所以可以从github和maven中央仓库来下载。
2.5.1. 源码下载
https://github.com/alibaba/dubbo
2.5.2. 发布包下载
http://repo1.maven.org/maven2/com/alibaba/dubbo/
3. 通过Maven编译构建dubbo
既然可以下载得到源码以及发布包,那么为什么要去构建dubbo呢?我们先来看下dubbo的主要模块:
其中,核心框架、管理控制台、简易监控中心、简易注册中心是我们需要的模块。目前只有核心模块jar包可以下载到,其它的均无法直接下载,所以我们需要构建dubbo。
3.1. 导入源码到IDEA
从githhub上下载dubbo源码得到dubbo-master.zip:
https://github.com/alibaba/dubbo
解压压缩包:
导入源码到IDEA:
右侧Maven Projects有红色报错信息,报maven插件无法加载,这个不要紧,待会编译打包Reimport一下即可!
如果POM文件有些划红线的地方也可不管,编译报错再详细分析。切勿编辑pom文件,可能造成一些换行等,编译pom文件会报无法解析(人品好的话编译不会报错,一次成功!)
3.2. 构建dubbo
在构建之前,各个源码包下面还没有target目录,构建成功之后,打好的jar包、war包会放到默认的输出目录下的target目录下。
配置运行参数:
点击运行按钮开始构建。
第一次构建耗时比较长,要联网下载许多jar包(建议使用阿里云的maven仓库)
maven_settings.xml中配置:
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
构建完成:
[INFO] Reactor Summary:
[INFO]
[INFO] dubbo-parent ....................................... SUCCESS [ 0.171 s]
[INFO] Hessian Lite(Alibaba embed version) ................ SUCCESS [ 6.314 s]
[INFO] dubbo-common ....................................... SUCCESS [ 6.943 s]
[INFO] dubbo-container .................................... SUCCESS [ 0.005 s]
[INFO] dubbo-container-api ................................ SUCCESS [ 1.129 s]
[INFO] dubbo-container-spring ............................. SUCCESS [ 1.416 s]
[INFO] dubbo-container-jetty .............................. SUCCESS [ 1.341 s]
[INFO] dubbo-container-log4j .............................. SUCCESS [ 1.343 s]
[INFO] dubbo-container-logback ............................ SUCCESS [ 1.416 s]
[INFO] dubbo-remoting ..................................... SUCCESS [ 0.004 s]
[INFO] dubbo-remoting-api ................................. SUCCESS [ 4.595 s]
[INFO] dubbo-remoting-netty ............................... SUCCESS [ 2.015 s]
[INFO] dubbo-remoting-mina ................................ SUCCESS [ 1.652 s]
[INFO] dubbo-remoting-grizzly ............................. SUCCESS [ 0.925 s]
[INFO] dubbo-remoting-p2p ................................. SUCCESS [ 1.690 s]
[INFO] dubbo-remoting-http ................................ SUCCESS [ 0.965 s]
[INFO] dubbo-remoting-zookeeper ........................... SUCCESS [ 1.657 s]
[INFO] dubbo-remoting-netty4 .............................. SUCCESS [ 2.108 s]
[INFO] dubbo-rpc .......................................... SUCCESS [ 0.004 s]
[INFO] dubbo-rpc-api ...................................... SUCCESS [ 2.920 s]
[INFO] dubbo-rpc-default .................................. SUCCESS [ 2.990 s]
[INFO] dubbo-rpc-injvm .................................... SUCCESS [ 1.493 s]
[INFO] dubbo-rpc-rmi ...................................... SUCCESS [ 1.602 s]
[INFO] dubbo-rpc-hessian .................................. SUCCESS [ 1.681 s]
[INFO] dubbo-rpc-http ..................................... SUCCESS [ 0.784 s]
[INFO] dubbo-rpc-webservice ............................... SUCCESS [ 1.870 s]
[INFO] dubbo-cluster ...................................... SUCCESS [ 3.492 s]
[INFO] dubbo-registry ..................................... SUCCESS [ 0.005 s]
[INFO] dubbo-registry-api ................................. SUCCESS [ 2.279 s]
[INFO] dubbo-monitor ...................................... SUCCESS [ 0.004 s]
[INFO] dubbo-monitor-api .................................. SUCCESS [ 1.530 s]
[INFO] dubbo-filter ....................................... SUCCESS [ 0.004 s]
[INFO] dubbo-filter-validation ............................ SUCCESS [ 0.899 s]
[INFO] dubbo-filter-cache ................................. SUCCESS [ 0.822 s]
[INFO] dubbo-registry-default ............................. SUCCESS [ 1.977 s]
[INFO] dubbo-monitor-default .............................. SUCCESS [ 1.567 s]
[INFO] dubbo-registry-multicast ........................... SUCCESS [ 1.674 s]
[INFO] dubbo-config ....................................... SUCCESS [ 0.004 s]
[INFO] dubbo-config-api ................................... SUCCESS [ 3.004 s]
[INFO] dubbo-config-spring ................................ SUCCESS [ 3.852 s]
[INFO] dubbo-rpc-thrift ................................... SUCCESS [ 3.846 s]
[INFO] dubbo-rpc-memcached ................................ SUCCESS [ 0.790 s]
[INFO] dubbo-rpc-redis .................................... SUCCESS [ 0.828 s]
[INFO] dubbo-registry-zookeeper ........................... SUCCESS [ 1.580 s]
[INFO] dubbo-registry-redis ............................... SUCCESS [ 1.641 s]
[INFO] dubbo .............................................. SUCCESS [ 39.232 s]
[INFO] dubbo-simple ....................................... SUCCESS [ 0.005 s]
[INFO] dubbo-registry-simple .............................. SUCCESS [ 4.940 s]
[INFO] dubbo-monitor-simple ............................... SUCCESS [ 9.127 s]
[INFO] dubbo-admin ........................................ SUCCESS [ 11.274 s]
[INFO] dubbo-demo ......................................... SUCCESS [ 0.004 s]
[INFO] dubbo-demo-api ..................................... SUCCESS [ 0.660 s]
[INFO] dubbo-demo-provider ................................ SUCCESS [ 3.590 s]
[INFO] dubbo-demo-consumer ................................ SUCCESS [ 3.541 s]
[INFO] dubbo-test ......................................... SUCCESS [ 0.004 s]
[INFO] dubbo-test-benchmark ............................... SUCCESS [ 4.688 s]
[INFO] dubbo-test-compatibility ........................... SUCCESS [ 0.041 s]
[INFO] dubbo-test-integration ............................. SUCCESS [ 0.044 s]
[INFO] dubbo-test-examples ................................ SUCCESS [ 3.082 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:39 min
[INFO] Finished at: 2017-11-19T14:33:11+08:00
[INFO] Final Memory: 41M/163M
[INFO] ------------------------------------------------------------------------
3.3. 找到对应的模块包
3.3.1. 核心框架
3.3.2. 管理控制台
3.3.3. 简易监控中心
3.3.4. 简易注册中心
4. Dubbo框架说明
4.1. 背景
4.2. 需求
4.3. 架构
调用关系:
1. 服务容器负责启动,加载,运行服务提供者。
2. 服务提供者在启动时,向注册中心注册自己提供的服务。
3. 服务消费者在启动时,向注册中心订阅自己所需的服务。
4. 注册中心返回服务提供者地址列表给消费者,如果有变更,注册中心将基于长连接推送变更数据给消费者。
5. 服务消费者,从提供者地址列表中,基于软负载均衡算法,选一台提供者进行调用,如果调用失败,再选另一台调用。
6. 服务消费者和提供者,在内存中累计调用次数和调用时间,定时每分钟发送一次统计数据到监控中心。
5. 快速入门
5.1. 实现功能
存在2个独立的系统,A系统和B系统。A系统调用B系统暴露的接口获取数据,比如查询用户列表。
5.2. 安装zookeeper
解压得到如下:
修改配置文件conf/zoo.cfg:设置data目录,该目录必须存在。
双击zkServer启动zookeeper服务(cmd文件是windows脚本,sh文件是linux下的脚本):
5.3. 搭建B系统(B模块)
5.3.1. 创建工程
新建一个maven项目
新建模块
上一步也可以不选骨架,这样生成的目录没有webapp目录,需要手动创建!并且手动改pom文件的packing类型为war
<packaging>war</packaging>
一路next,直到finish。
5.3.2. 导入依赖
编辑模块systemB的pom文件:
Dubbo核心jar可以先install到本地maven仓库。其实如果联网,一旦保存pom文件,maven工具会自动远程仓库下载
<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/maven-v4_0_0.xsd">
<parent>
<artifactId>dubbodemo</artifactId>
<groupId>cn.com.zpc</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>systemB</artifactId>
<packaging>war</packaging>
<name>systemB Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- 采用spring配置方式使用dubbo,所以需要导入spring容器依赖-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.7</version>
<!-- 排除传递spring依赖-->
<exclusions>
<exclusion>
<artifactId>spring</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-web</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-context</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>systemB</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8081</port>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
5.3.3. 配置log4j文件
在resources下新建log4j.properties:
log4j.rootLogger=DEBUG,A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c]-[%p] %m%n
5.3.4. 创建User对象
package com.zpc.dubbo.systemb.pojo;
public class Userimplements java.io.Serializable{
private static final longserialVersionUID = -2668999087589887337L;
privateLong id;
privateString username;
privateString password;
privateInteger age;
publicLong getId() {
returnid;
}
public voidsetId(Longid) {
this.id= id;
}
publicString getUsername() {
returnusername;
}
public voidsetUsername(Stringusername) {
this.username= username;
}
publicString getPassword() {
returnpassword;
}
public voidsetPassword(Stringpassword) {
this.password= password;
}
publicInteger getAge() {
returnage;
}
public voidsetAge(Integerage) {
this.age= age;
}
}
5.3.5. 创建UserService(接口)并提供查询服务
package com.zpc.dubbo.systemb.service;
import com.zpc.dubbo.systemb.pojo.User;
import java.util.List;
public interface UserService{
/**
* 查询所有的用户数据
*/
publicList<User>queryAll();
}
5.3.6. 创建UserServiceImpl实现类
package com.zpc.dubbo.systemb.service.impl;
import com.zpc.dubbo.systemb.pojo.User;
import com.zpc.dubbo.systemb.service.UserService;
import java.util.ArrayList;
import java.util.List;
public class UserServiceImplimplements UserService{
/**
* 实现查询,这里做模拟实现,不做具体的数据库查询
*/
@Override
publicList<User>queryAll() {
List<User>list =new ArrayList<User>();
for(inti =0;i <10;i++) {
Useruser =new User();
user.setAge(20+ i);
user.setId(Long.valueOf(i+ 1));
user.setPassword("123456");
user.setUsername("username_"+ i);
list.add(user);
}
returnlist;
}
}
5.3.7. 编写dubbo配置文件
dubbo-provider.xml
具体配置:
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 提供方应用信息,用于计算依赖关系 -->
<dubbo:applicationname="dubbo-b-provider"/>
<!-- 这里使用的注册中心是zookeeper -->
<dubbo:registryaddress="zookeeper://127.0.0.1:2181"client="zkclient"/>
<!-- 用dubbo协议在20880端口暴露服务 -->
<dubbo:protocolname="dubbo"port="20880"/>
<!-- 将该接口暴露到dubbo中 -->
<dubbo:serviceinterface="com.zpc.dubbo.systemb.service.UserService"ref="userServiceImpl"/>
<!-- 将具体的实现类加入到Spring容器中 -->
<beanid="userServiceImpl"class="com.zpc.dubbo.systemb.service.impl.UserServiceImpl"/>
</beans>
5.3.8. 导入zookeeper依赖
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.8</version>
</dependency>
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>0.1</version>
</dependency>
5.3.9. 编写Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>dubbo-b</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:dubbo/dubbo-*.xml</param-value>
</context-param>
<!--Spring的ApplicationContext载入 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
5.3.10. 启动tomcat
使用maven插件启动服务器:
查看tomcat启动日志:
2017-11-19 16:49:45,033 [DubboZkclientConnector-SendThread(127.0.0.1:2181)] [org.apache.zookeeper.ClientCnxn]-[INFO]Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2017-11-19 16:49:45,034 [DubboZkclientConnector-SendThread(127.0.0.1:2181)] [org.apache.zookeeper.ClientCnxn]-[INFO]Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session
2017-11-19 16:49:45,035 [DubboZkclientConnector-SendThread(127.0.0.1:2181)] [org.apache.zookeeper.ClientCnxn]-[DEBUG] Session establishment request sent on 127.0.0.1/127.0.0.1:2181
2017-11-19 16:49:45,190 [DubboZkclientConnector-SendThread(127.0.0.1:2181)] [org.apache.zookeeper.ClientCnxn]-[INFO] Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x15fd342ea0c0000, negotiated timeout = 30000
2017-11-19 16:49:45,191 [DubboZkclientConnector-EventThread] [org.I0Itec.zkclient.ZkClient]-[DEBUG] Received event: WatchedEvent state:SyncConnected type:None path:null
2017-11-19 16:49:45,192 [DubboZkclientConnector-EventThread] [org.I0Itec.zkclient.ZkClient]-[INFO] zookeeper state changed (SyncConnected)
2017-11-19 16:49:45,192 [DubboZkclientConnector-EventThread] [org.I0Itec.zkclient.ZkClient]-[DEBUG] Leaving process event
2017-11-19 16:49:45,192 [DubboZkclientConnector] [org.I0Itec.zkclient.ZkClient]-[DEBUG] State is SyncConnected
2017-11-19 16:49:45,194 [localhost-startStop-1] [com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry]-[INFO] [DUBBO]Register: dubbo://192.168.181.1:20880/com.zpc.dubbo.systemb.service.UserService?anyhost=true&application=dubbo-b-provider&dubbo=2.5.7&generic=false&interface=com.zpc.dubbo.systemb.service.UserService&methods=queryAll&pid=5564&side=provider×tamp=1511081384696, dubbo version: 2.5.7, current host: 127.0.0.1
2017-11-19 16:49:45,209 [DubboZkclientConnector-SendThread(127.0.0.1:2181)] [org.apache.zookeeper.ClientCnxn]-[DEBUG] Reading reply sessionid:0x15fd342ea0c0000, packet:: clientPath:null serverPath:null finished:false header:: 1,3 replyHeader:: 1,569,-101 request:: '/dubbo/com.zpc.dubbo.systemb.service.UserService/providers,F response::
可以看到,已经将UserService服务注册到zookeeper注册中心,协议采用的是dubbo。
Zookeeper控制台显示收到连接:
5.4. 搭建A系统(A模块)
5.4.1. 创建工程
步骤可以参照搭建B系统!A系统创建完成:
5.4.2. 导入依赖
A系统的pom文件:参考B系统,一模一样!
5.4.3. 配置log4j文件
log4j.properties(和B系统一样配置即可):
log4j.rootLogger=DEBUG,A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c]-[%p] %m%n
5.4.4. 从B系统中拷贝User对象、UserService接口到A系统
注意是从B系统完全拷贝到A系统,包名不能改动!
5.4.5. 编写A系统的dubbo配置文件
dubbo-consumer.xml:
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 提供方应用信息,用于计算依赖关系 -->
<dubbo:applicationname="dubbo-a-consumer"/>
<!-- 这里使用的注册中心是zookeeper -->
<dubbo:registryaddress="zookeeper://127.0.0.1:2181"client="zkclient"/>
<!-- 从注册中心中查找服务 -->
<dubbo:referenceid="userService"interface="com.zpc.dubbo.systemb.service.UserService"/>
</beans>
5.4.6. 编写UserService测试用例
package com.zpc.dubbotest;
import com.zpc.dubbo.systemb.pojo.User;
import com.zpc.dubbo.systemb.service.UserService;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.List;
public class TestUserService{
privateUserService userService;
@Before
public voidsetUp()throws Exception{
ApplicationContextapplicationContext =new ClassPathXmlApplicationContext(
"classpath:dubbo/*.xml");
this.userService= applicationContext.getBean(UserService.class);
}
@Test
public voidtestQueryAll() {
List<User>users =this.userService.queryAll();
for(Useruser :users) {
System.out.println(user);
}
}
}
5.4.7. 查看效果
(重写了User的toString方法!)
把zookeeper、B系统运行起来,再运行A系统的测试用例:
可以看到,已经查询到10条数据,那么,也就是说A系统通过B系统提供的服务获取到了数据。
5.5. 解决代码重复问题
通过刚刚的示例我们可以发现,其中User对象和UserService在A系统和B系统中都使用,那么,我们是否应该将该代码复用,而不用硬拷贝?
答案是肯定的。
在使用dubbo时,provider需要将提供服务所需要的java代码(bean、interface等)单独打包成jar提供给consumer使用。
5.5.1. 创建dubbo_systemB_api模块
5.5.2. 将systemB中的pojo和service接口剪切到dubbo-systemB-api中
注意:B系统和A系统的pojo与service接口全部删除,全部直接依赖dubbo-systemB-api!
5.5.3. 在systemB的pom.xml文件中添加dubbo-systemB-api的依赖,并且将pojo与service接口删除
<dependency>
<groupId>cn.com.zpc</groupId>
<artifactId>dubbo_systemB_api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
修改dubbo-provider.xml
<!-- 将该接口暴露到dubbo中 -->
<dubbo:serviceinterface="com.zpc.systemb.api.service.UserService"ref="userServiceImpl"/>
5.5.4. 在systemA的pom.xml文件中添加dubbo-systemB-api的依赖,并且将pojo与service接口删除
<dependency>
<groupId>cn.com.zpc</groupId>
<artifactId>dubbo_systemB_api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
修改dubbo-consumer.xml
<!-- 从注册中心中查找服务 -->
<dubbo:referenceid="userService"interface="com.zpc.systemb.api.service.UserService"/>
此时目录结构如下(只有api包中保留接口和pojo类定义):
5.5.5. 测试
测试之前先rebuild项目!
依次启动zookeeper和系统B,再运行系统A中的测试用例!
测试,发现,和之前实现一样。
其实也可以把接口保留B系统中(毕竟B系统提供的服务嘛)。然后在A系统中直接依赖B系统的jar包即可。
6. 管理界面
dubbo提供了一套在线管理整个服务的功能,管理控制台为阿里内部裁剪版本,开源部分主要包含:路由规则,动态配置,服务降级,访问控制,权重调整,负载均衡,等管理功能。
6.1. 安装
将dubbo-admin-2.5.7.war部署解压到tomcat的webapps目录下的ROOT目录(删除里面的内容)里:
6.2. 修改配置文件
6.3. 启动tomcat
6.4. 查看管理界面
使用如下用户登录(密码和用户名一致,如root/root):
Tomcat端口未必是8080,看自己怎么配的。
效果:
功能:
提供者:
消费者:
应用:
<!-- 从注册中心中查找服务 -->
<dubbo:referenceid="userService"interface="com.zpc.systemb.api.service.UserService"/>
[INFO] Reactor Summary:
[INFO]
[INFO] dubbo-parent ....................................... SUCCESS [ 0.171 s]
[INFO] Hessian Lite(Alibaba embed version) ................ SUCCESS [ 6.314 s]
[INFO] dubbo-common ....................................... SUCCESS [ 6.943 s]
[INFO] dubbo-container .................................... SUCCESS [ 0.005 s]
[INFO] dubbo-container-api ................................ SUCCESS [ 1.129 s]
[INFO] dubbo-container-spring ............................. SUCCESS [ 1.416 s]
[INFO] dubbo-container-jetty .............................. SUCCESS [ 1.341 s]
[INFO] dubbo-container-log4j .............................. SUCCESS [ 1.343 s]
[INFO] dubbo-container-logback ............................ SUCCESS [ 1.416 s]
[INFO] dubbo-remoting ..................................... SUCCESS [ 0.004 s]
[INFO] dubbo-remoting-api ................................. SUCCESS [ 4.595 s]
[INFO] dubbo-remoting-netty ............................... SUCCESS [ 2.015 s]
[INFO] dubbo-remoting-mina ................................ SUCCESS [ 1.652 s]
[INFO] dubbo-remoting-grizzly ............................. SUCCESS [ 0.925 s]
[INFO] dubbo-remoting-p2p ................................. SUCCESS [ 1.690 s]
[INFO] dubbo-remoting-http ................................ SUCCESS [ 0.965 s]
[INFO] dubbo-remoting-zookeeper ........................... SUCCESS [ 1.657 s]
[INFO] dubbo-remoting-netty4 .............................. SUCCESS [ 2.108 s]
[INFO] dubbo-rpc .......................................... SUCCESS [ 0.004 s]
[INFO] dubbo-rpc-api ...................................... SUCCESS [ 2.920 s]
[INFO] dubbo-rpc-default .................................. SUCCESS [ 2.990 s]
[INFO] dubbo-rpc-injvm .................................... SUCCESS [ 1.493 s]
[INFO] dubbo-rpc-rmi ...................................... SUCCESS [ 1.602 s]
[INFO] dubbo-rpc-hessian .................................. SUCCESS [ 1.681 s]
[INFO] dubbo-rpc-http ..................................... SUCCESS [ 0.784 s]
[INFO] dubbo-rpc-webservice ............................... SUCCESS [ 1.870 s]
[INFO] dubbo-cluster ...................................... SUCCESS [ 3.492 s]
[INFO] dubbo-registry ..................................... SUCCESS [ 0.005 s]
[INFO] dubbo-registry-api ................................. SUCCESS [ 2.279 s]
[INFO] dubbo-monitor ...................................... SUCCESS [ 0.004 s]
[INFO] dubbo-monitor-api .................................. SUCCESS [ 1.530 s]
[INFO] dubbo-filter ....................................... SUCCESS [ 0.004 s]
[INFO] dubbo-filter-validation ............................ SUCCESS [ 0.899 s]
[INFO] dubbo-filter-cache ................................. SUCCESS [ 0.822 s]
[INFO] dubbo-registry-default ............................. SUCCESS [ 1.977 s]
[INFO] dubbo-monitor-default .............................. SUCCESS [ 1.567 s]
[INFO] dubbo-registry-multicast ........................... SUCCESS [ 1.674 s]
[INFO] dubbo-config ....................................... SUCCESS [ 0.004 s]
[INFO] dubbo-config-api ................................... SUCCESS [ 3.004 s]
[INFO] dubbo-config-spring ................................ SUCCESS [ 3.852 s]
[INFO] dubbo-rpc-thrift ................................... SUCCESS [ 3.846 s]
[INFO] dubbo-rpc-memcached ................................ SUCCESS [ 0.790 s]
[INFO] dubbo-rpc-redis .................................... SUCCESS [ 0.828 s]
[INFO] dubbo-registry-zookeeper ........................... SUCCESS [ 1.580 s]
[INFO] dubbo-registry-redis ............................... SUCCESS [ 1.641 s]
[INFO] dubbo .............................................. SUCCESS [ 39.232 s]
[INFO] dubbo-simple ....................................... SUCCESS [ 0.005 s]
[INFO] dubbo-registry-simple .............................. SUCCESS [ 4.940 s]
[INFO] dubbo-monitor-simple ............................... SUCCESS [ 9.127 s]
[INFO] dubbo-admin ........................................ SUCCESS [ 11.274 s]
[INFO] dubbo-demo ......................................... SUCCESS [ 0.004 s]
[INFO] dubbo-demo-api ..................................... SUCCESS [ 0.660 s]
[INFO] dubbo-demo-provider ................................ SUCCESS [ 3.590 s]
[INFO] dubbo-demo-consumer ................................ SUCCESS [ 3.541 s]
[INFO] dubbo-test ......................................... SUCCESS [ 0.004 s]
[INFO] dubbo-test-benchmark ............................... SUCCESS [ 4.688 s]
[INFO] dubbo-test-compatibility ........................... SUCCESS [ 0.041 s]
[INFO] dubbo-test-integration ............................. SUCCESS [ 0.044 s]
[INFO] dubbo-test-examples ................................ SUCCESS [ 3.082 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:39 min
[INFO] Finished at: 2017-11-19T14:33:11+08:00
[INFO] Final Memory: 41M/163M
[INFO] ------------------------------------------------------------------------
1.Dubbo教程的更多相关文章
- Dubbo教程:入门到实战
Dubbox简介 Dubbox 是一个分布式服务框架,其前身是阿里巴巴开源项目Dubbo ,被国内电商及互联网项目中使用,后期阿里巴巴停止了该项目的维护,当当网便在Dubbo基础上进行优化,并继续维护 ...
- dubbo 教程
阿里巴巴dubbo主页:http://code.alibabatech.com/wiki/display/dubbo/Home-zh 1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提 ...
- [推荐]dubbo分布式服务框架知识介绍
[推荐]dubbo分布式服务框架知识介绍 CentOS+Jdk+Jboss+dubbo+zookeeper集群配置教程 http://wenku.baidu.com/view/20e8f36bf ...
- dubbo,gradle,spring build from source
https://github.com/alibaba/dubbo http://www.csdn.net/article/2012-11-13/2811827-alibaba-Dubbo-Distri ...
- Dubbo(二) 认识Zookeeper
前言 在昨天,我们给大家基本介绍了Dubbo,文中反复提到了Zookeeper,那么它到底是什么呢,这篇文章我们将从Dubbo层面去了解Zookeeper,不做全面讲解,毕竟这是Dubbo教程啊~ Z ...
- 传统开发有必要学Dubbo吗
dubbo作为一个知名的分布式服务调用框架,在众多互联网公司都有广泛的应用.但其本质还是一个远程服务调用框架,最初就是为了应对SOA服务治理时才用到的,如果本身服务不多就没必要用它了.如果对技术感兴趣 ...
- dubbo简单示例
dubbo简单示例 2019-09-06 1 Zookeeper注册中心的搭建(windows单机) 下载zookeeper压缩包并解压到 D:\zookeeper\apache-zookeeper- ...
- Dubbo从入门到实战视频教程
Dubbo是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和 Spring框架无缝集成.这里整理了一套关于dubbo的视频教程分享给大家,包 ...
- Dubbo | Dubbo快速上手笔记 - 环境与配置
目录 前言 1. Dubbo相关概念 1.1 自动服务发现工作原理 2. 启动文件 2.1 zookeeper-3.4.11\bin\zkServer.cmd 2.2 zookeeper-3.4.11 ...
随机推荐
- POJ 1459 最大流 第二题
http://poj.org/problem?id=1459 也是网络流的基础,只是虚拟出一个源点和终点,对应的生产值和消费值就加到与源点和终点的边上,然后做一次bfs就好了. #include &l ...
- Flutter入门
1.安装SDK 官网下载其最新可用的安装包并解压. 设置环境变量:在.bash_profile文件中写入export PATH=/Users/malk/Documents/flutter/bin:$P ...
- vue 指令的用法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Codefroces432 div2 A,B,C
A. Arpa and a research in Mexican wave Arpa is researching the Mexican wave. There are n spectators ...
- AIX 软件包结构
AIX installp软件包结构 1. usr部分 2. / (root)部分 3. share部分 AIX 为了实现在客户机 / 服务器环境下安装的灵活性将安装包划分为 usr 部分 .r ...
- Flex4之事件详解
第一.Flex事件简介 事件贯穿于Flex应用开发的全过程.事件是ActionScript .0中最重要的部分之一,也是Flex应用程序开发的核心基础.本章将在DOM 3的基础上详细讲解ActionS ...
- UVC和V4L2的关系(转载)
UVC是一种usb视频设备驱动.用来支持usb视频设备,凡是usb接口的摄像头都能够支持 V4L2是Linux下的视频采集框架.用来统一接口,向应用层提供API UVC: USB video clas ...
- BZOJ——T 3732: Network
http://www.lydsy.com/JudgeOnline/problem.php?id=3732 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: ...
- 【VC编程技巧】窗口☞3.4利用bitmap改变对话框的背景。
效果图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2hlbl9qaW50/font/5a6L5L2T/fontsize/400/fill/I0JBQ ...
- POJ 2104 K-th Number 静态主席树(裸
题目链接:点击打开链接 题意: 给定n长的序列.q个询问 以下n个数字给出序列 每一个询问[l, r] k ,输出该区间中第k大的数 先建一个n个节点的空树.然后每次从后往前新建一棵树,依附原来的空树 ...