说一下dubbo项目简单的搭建过程_如何在本地搭建一个简单 dubbo 项目

如何在本地搭建一个简单 dubbo 项目

zookooper 下载

官网:

下载镜像

下载之后解压到无中文无特殊字符路径中:

445f86097ea01957e24d58916fbf5219.png

修改 conf/zoo_sample.cfg 为 zoo.cfg

c1822e0268bf55fba76004d3db3326f3.png

zoo.cfg 内容如下:

# The number of milliseconds of each tick

tickTime=2000

# The number of ticks that the initial

# synchronization phase can take

initLimit=10

# The number of ticks that can pass between

# sending a request and getting an acknowledgement

syncLimit=5

# the directory where the snapshot is stored.

# do not use /tmp for storage, /tmp here is just

# example sakes.

dataDir=D:\\09tmp\\zookeeper

# the port at which the clients will connect

clientPort=2181

启动 zookeeper

双击 bin/zkServer.cmd

6f3759f4f4517379765222297ba6be86.png

dubbo 服务提供者代码编写,启动类、接口类、接口实现类。

//启动类

public class Application {

public static void main(String[] args) throws Exception {

ServiceConfig service = new ServiceConfig<>();

service.setApplication(new ApplicationConfig("dubbo-demo-api-provider"));

service.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));

service.setInterface(DemoService.class);

service.setRef(new DemoServiceImpl());

service.export();

System.in.read();

}

}

//服务接口类

public interface DemoService {

String sayHello(String name);

String show();

String getName(String name);

}

//接口实现类

public class DemoServiceImpl implements DemoService {

@Override

public String sayHello(String name) {

return "Hello " + name + ", response from provider: " + RpcContext.getContext().getLocalAddress();

}

@Override

public String show() {

return "show , response from provider: " + RpcContext.getContext().getLocalAddress();

}

@Override

public String getName(String name) {

return name + ", response from provider: " + RpcContext.getContext().getLocalAddress();

}

}

安装 dubbo-admin.war,查看 dubbo 接口信息。

准备好 dubbo-admin.war 之后放到 tomcat/webapp 中

09478deec601eef8df1a73cff3eeab6b.png

启动 Tomcat,输入 Tomcat 对应端(本案例是 7070,需要自己设定)口加上 dubbo-admin-2.6.0 项目名

acf1421b0025dd7e457b8639d3c3348e.png

输入服务名称点击搜索按钮

4bc884355e7b50a6fbe283b5dc14fcd0.png

点击 IP 地址查看详细信息

45c30785c8a61838540439582450002e.png

OK,这样咱们一个简单的 dubbo 服务提供者的环境就搭建完毕了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值