[报错]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.<init>(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}
)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。