Dubbo和zookeeper整合springboot报错:An attempt was made to call a method that does not exist. The attempt was made from the following location(已解决)

Description:

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

    org.elasticsearch.transport.netty4.Netty4InternalESLogger.<init>(Netty4InternalESLogger.java:34)

The following method did not exist:

    org.elasticsearch.common.logging.Loggers.getLogger(Ljava/lang/String;)Lorg/apache/logging/log4j/Logger;

The method's class, org.elasticsearch.common.logging.Loggers, is available from the following locations:

    jar:file:/Users/admin/.m2/repository/org/elasticsearch/elasticsearch/6.8.4/elasticsearch-6.8.4.jar!/org/elasticsearch/common/logging/Loggers.class

It was loaded from the following location:

    file:/Users/admin/.m2/repository/org/elasticsearch/elasticsearch/6.8.4/elasticsearch-6.8.4.jar

这句话的意思是:还没有启动成功就报错了.报错原因,说jar包的位置不对,根本原因就是pom.xml文件中版本依赖有问题,比如你的项目依赖的是2.1.0版本的工程,你其他的子依赖,必须也是2.1.0!

如果你写了两个模块,那么一定要看看pom.xml上面的这段代码:

<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>

很有可能就是,底下这个版本号的问题,我原先的是3点几的,就报错了,改成这个就可以了。

下面是dubbo和zookeeper整合springboot的所有依赖,亲测可用

<?xml version="1.0" encoding="UTF-8"?>
<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 https://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>2.2.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.kuang</groupId>
    <artifactId>provider</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>provider</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <!--导入依赖:Dubbo+zookeeper-->
        <!-- https://mvnrepository.com/artifact/org.apache.dubbo/dubbo-spring-boot-starter -->
        <dependency>
        <groupId>org.apache.dubbo</groupId>
        <artifactId>dubbo-spring-boot-starter</artifactId>
        <version>2.7.3</version>
    </dependency>
        <!--zkClient-->
        <!-- https://mvnrepository.com/artifact/com.github.sgroschupf/zkclient -->
        <dependency>
            <groupId>com.github.sgroschupf</groupId>
            <artifactId>zkclient</artifactId>
            <version>0.1</version>
        </dependency>
        <!--日志会冲突-->
        <!--引入zookeeper-->
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-framework</artifactId>
            <version>2.12.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-recipes</artifactId>
            <version>2.12.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
            <version>3.4.14</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>




        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐