java.lang.IllegalStateException: Failed to introspect Class

后端 未结 2 1904
难免孤独
难免孤独 2021-01-04 07:56

I am trying to add Elasticsearch to my project. I have affffded the necessary dependencies to my pom.xml file. When I run the server I am getting this error:

相关标签:
2条回答
  • 2021-01-04 08:57

    You need to add spring-data-elasticsearch.jar file into your class path. The error is showing because of this small mistake.

    0 讨论(0)
  • 2021-01-04 08:59

    Caused by: java.lang.ClassNotFoundException: org.springframework.data.elasticsearch.core.ElasticsearchOperations

    This error message means that the jar containing this class is not on the application classpath.

    Add spring-data-elasticsearch jar to it, and your error should be gone.

    if you are using maven, add the jar to the classpath this way :

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
        <version>3.2.5.RELEASE</version>
    </dependency>
    

    The version that you should use depends on the version of elastic search you are connecting to :

    +--------------+----------------------------+----------------+-------------+
    | Spring Data  | Spring Data Elasticsearch  | Elasticsearch  | Spring Boot |
    +--------------+----------------------------+----------------+-------------+
    | 2020.0.0     | 4.1.x                      |          7.9.3 | 2.3.x       |
    | Neumann      | 4.0.x                      |          7.6.2 | 2.3.x       |
    | Moore        | 3.2.x                      |          6.8.4 | 2.2.x       |
    | Lovelace     | 3.1.x                      |          6.2.2 | 2.1.x       |
    | Kay          | 3.0.x                      |          5.5.0 | 2.0.x       |
    | Ingalls      | 2.1.x                      |          2.4.0 | 1.5.x       |
    +--------------+----------------------------+----------------+-------------+
    

    (source : https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#preface.versions )

    0 讨论(0)
提交回复
热议问题