[报错]An attempt was made to call the method org.elasticsearch.client.RestHighLevelClient

完整报错:

Description:

An attempt was made to call the method org.elasticsearch.client.RestHighLevelClient.(Lorg/elasticsearch/client/RestClientBuilder;)V but it does not exist. Its class, org.elasticsearch.client.RestHighLevelClient, is available from the following locations:

    jar:file:/Users/user/.m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/5.6.10/elasticsearch-rest-high-level-client-5.6.10.jar!/org/elasticsearch/client/RestHighLevelClient.class

It was loaded from the following location:

    file:/Users/user/.m2/repository/org/elasticsearch/client/elasticsearch-rest-high-level-client/5.6.10/elasticsearch-rest-high-level-client-5.6.10.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.client.RestHighLevelClient

解决:

@SpringBootApplication(
        scanBasePackages = {
                "$packages$"
        },
//加上这行,阻止springboot自己注入对象:
        exclude={ElasticsearchAutoConfiguration.class, RestClientAutoConfiguration.class}
)

你可能感兴趣的:([报错]An attempt was made to call the method org.elasticsearch.client.RestHighLevelClient)