Spring Boot 中使用 Dubbo + Zookeeper 实现远程调用

Spring Boot 中使用 Dubbo + Zookeeper 实现远程调用

出现的报错

1.zk 版本问题

2021-11-18 09:53:51.972 ERROR 10448 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.apache.curator.framework.imps.EnsembleTracker.<init>(EnsembleTracker.java:57)

The following method did not exist:

    org.apache.zookeeper.server.quorum.flexible.QuorumMaj.<init>(Ljava/util/Map;)V

The method's class, org.apache.zookeeper.server.quorum.flexible.QuorumMaj, is available from the following locations:

    jar:file:/E:/apache-maven-3.0.5/repositories/org/apache/zookeeper/zookeeper/3.4.13/zookeeper-3.4.13.jar!/org/apache/zookeeper/server/quorum/flexible/QuorumMaj.class

It was loaded from the following location:

    file:/E:/apache-maven-3.0.5/repositories/org/apache/zookeeper/zookeeper/3.4.13/zookeeper-3.4.13.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.apache.zookeeper.server.quorum.flexible.QuorumMaj

2021-11-18 09:53:56.433  INFO 10448 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'

本地使用的pom依赖,使用的是 dobbo 3.2.6运行时绑定的zk版本为3.4.13,版本过低

    <dependency>
        <groupId>org.apache.dubbo</groupId>
        <artifactId>dubbo-dependencies-zookeeper</artifactId>
        <version>3.2.6</version>
        <type>pom</type>
        <exclusions>
            <exclusion>
                <artifactId>slf4j-reload4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.dubbo/dubbo -->
    <dependency>
        <groupId>org.apache.dubbo</groupId>
        <artifactId>dubbo</artifactId>
        <version>3.2.6</version>
    </dependency>

解决方法:升级zk的版本

注意:需要排除掉原先dubbo-dependencies-zookeeper中的zk

    <dependency>
        <groupId>org.apache.dubbo</groupId>
        <artifactId>dubbo-dependencies-zookeeper</artifactId>
        <version>3.2.6</version>
        <type>pom</type>
        <exclusions>
            <exclusion>
                <artifactId>slf4j-reload4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
            <exclusion>
                <artifactId>zookeeper</artifactId>			//排除zk
                <groupId>org.apache.zookeeper</groupId>
            </exclusion>
        </exclusions>
    </dependency>    

	<dependency>
        <groupId>org.apache.zookeeper</groupId>
        <artifactId>zookeeper</artifactId>
        <version>3.6.1</version>
        <exclusions>
            <exclusion>
                <artifactId>slf4j-reload4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>

2.qos-server问题

[ERROR]  [DUBBO] qos-server can not bind localhost:22222, dubbo version: 2.6.4, current host: 169.254.68.252
java.net.BindException: Address already in use: bind

什么是QoS
Qos=Quality of Service,qos是Dubbo的在线运维命令,可以对服务进行动态的配置、控制及查询,Dubboo2.5.8新版本重构了telnet(telnet是从Dubbo2.0.5开始支持的)模块,提供了新的telnet命令支持,新版本的telnet端口与dubbo协议的端口是不同的端口,默认为22222,可以通过配置文件dubbo.properties修改。telnet 模块现在同时支持 http 协议和 telnet 协议,方便各种情况的使用。

意思就是端口被占用了,我们需要修改端口

因此只需要在配置中添加:

dubbo:
  application:
    name: myProvider	#自己取名
    qos-enable: false
    qos-port: 33333
    qos-accept-foreign-ip: false

3.包路径问题

com.lin.backend.provider

Failed to check the status of the service com.lin.backend.provider.DemoService. No provider available for the service com.lin.backend.provider.DemoService from the url consumer://192.168.124.4/com.lin.backend.provider

我的服务提供者的接口路径和服务消费者的接口路径不一致
只需要修改两个项目中的包路径即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值