Elasticsearch升级(2.4到5.0.1)。类无法解析 - 间接引用错误

时间:2016-12-09 13:16:37

标签: java spring elasticsearch upgrade spring-data-elasticsearch

我正在尝试将我们的Elasticsearch版本从2.4升级到5.0.1,并且我收到了这些错误:

1. ERROR in D:\Projects\projectname\projectname.persistence.elasticsearch\src\main\java\com\path\to\some\repository\ElasticCategoryRepository.java (at line 1)
        package com.path.to.some.repository;
        ^
The type org.elasticsearch.search.highlight.HighlightBuilder$Field cannot be resolved. It is indirectly referenced from required .class files
----------
----------
2. ERROR in D:\Projects\projectname\projectname.persistence.elasticsearch\src\main\java\com\path\to\some\config\ElasticSearchConfiguration.java (at line 1)
        package com.path.to.some.config;
        ^
The type org.elasticsearch.search.suggest.SuggestBuilder$SuggestionBuilder cannot be resolved. It is indirectly referenced from required .class files

Elasticsearch版本:5.0.1

Spring Data Elasticsearch版本:2.0.5

这是错误#2的配置类:

@Configuration
public class ElasticSearchConfiguration {
    public static final String ELASTICSEARCH_CLIENT_BEAN_NAME = "elasticSearchClient";
    @Autowired
    @Qualifier(ELASTICSEARCH_CLIENT_BEAN_NAME)
    private Client client;

    @Bean
    public ElasticsearchOperations elasticsearchTemplate() {
        return new ElasticsearchTemplate(client);
    }


    @PreDestroy
    public void closeClient(){
        client.close();
    }
}

这是我们的远程弹性搜索配置类:

@Profile("!" + Profiles.REMOTE_STORAGE_OFF)
@Configuration
public class RemoteElasticSearchConfiguration {
    @Value("${projectname.elasticsearch.remote.cluster.name}")
    private String clusterName;
    @Value("${projectname.elasticsearch.remote.node.host}")
    private String clusterNodeHost;
    @Value("${projectname.elasticsearch.remote.node.port}")
    private Integer clusterNodePort;
    @Value("${projectname.elasticsearch.remote.client.transport.sniff}")
    private Boolean sniffTransport;

    @SneakyThrows
    @Bean(name = ElasticSearchConfiguration.ELASTICSEARCH_CLIENT_BEAN_NAME)
    public Client remoteElasticSearchClient() {
        Settings settings = Settings.builder()
                .put("cluster.name", clusterName)
                .put("client.transport.sniff", sniffTransport)
                .build();
        TransportClient client = new PreBuiltTransportClient(settings);
        client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(clusterNodeHost), clusterNodePort));
        return client;
    }

}

我已经搜索了一下,发现有类似错误的人,但他们的问题是该类不再是弹性搜索的一部分,这不是我案例中的原因。我想这可能是依赖关系的问题,但我不知道从哪里开始挖掘。任何帮助赞赏。感谢。

编辑:添加了pom属性和依赖项:

<properties>
        <!-- Libraries -->
        <lombok.version>1.16.10</lombok.version>
        <spring.version>4.3.2.RELEASE</spring.version>
        <spring.security.version>4.1.2.RELEASE</spring.security.version>
        <spring.data.elasticsearch.version>2.0.5.RELEASE</spring.data.elasticsearch.version>
        <javax.servlet>3.1.0</javax.servlet>
        <jsoup.version>1.7.2</jsoup.version>
        <commons.io.version>2.4</commons.io.version>
        <hamcrest.version>1.3</hamcrest.version>
        <mockito.version>1.9.5</mockito.version>
        <junit.version>4.12</junit.version>
        <easytesting.version>1.4</easytesting.version>
        <groovy.version>2.4.3</groovy.version>
        <spock.version>0.7-groovy-2.0</spock.version>
        <cglib.version>3.1</cglib.version>
        <tomcat.version>7.0.57</tomcat.version>
        <hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
        <hibernate.version>4.3.10.Final</hibernate.version>
        <javax.validation.version>1.1.0.Final</javax.validation.version>
        <jclouds.version>1.9.0</jclouds.version>
        <aspectj.version>1.8.6</aspectj.version>
        <jackson.version>2.8.2</jackson.version>
        <camel.version>2.17.3</camel.version>
        <slf4j.version>1.7.12</slf4j.version>
        <log4j.version>1.2.17</log4j.version>
        <guava.version>18.0</guava.version>
        <joda.time.version>2.7</joda.time.version>
        <jaxb.sun.version>2.2.11</jaxb.sun.version>
        <jaxb.api.version>2.2.12</jaxb.api.version>
        <prettytime.version>4.0.0.Final</prettytime.version>
        <httpclient.version>4.4.1</httpclient.version>
        <dozer.version>5.5.1</dozer.version>
        <elastic.search.version>5.0.1</elastic.search.version>

        <!-- Project -->
        <tomcat.http.port>9090</tomcat.http.port>
        <spring.profiles>dev</spring.profiles>
        <application.home>${java.io.tmpdir}/${project.build.finalName}</application.home>
        <java-version>1.8</java-version>
        <project.finalName>${project.artifactId}</project.finalName>
        <skipTests>false</skipTests>
        <buildnumber-maven-plugin.doCheck>true</buildnumber-maven-plugin.doCheck>
        <buildnumber-maven-plugin.doUpdate>true</buildnumber-maven-plugin.doUpdate>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <buildTimestamp>${maven.build.timestamp}</buildTimestamp>
    </properties>
    <dependencyManagement>
        <dependencies>
            <!-- lombok -->
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
            </dependency>

            <!-- Persistence -->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>${hibernate-validator.version}</version>
            </dependency>

            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>${hibernate.version}</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>${hibernate.version}</version>
            </dependency>

            <dependency>
                <groupId>javax.validation</groupId>
                <artifactId>validation-api</artifactId>
                <version>${javax.validation.version}</version>
            </dependency>

            <!--apache jclouds-->
            <dependency>
                <groupId>org.apache.jclouds</groupId>
                <artifactId>jclouds-all</artifactId>
                <version>${jclouds.version}</version>
            </dependency>

            <!-- Spring -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-oxm</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-elasticsearch</artifactId>
                <version>${spring.data.elasticsearch.version}</version>
            </dependency>

            <!-- AOP -->
            <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>${aspectj.version}</version>
            </dependency>

            <!-- Jackson -->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.dataformat</groupId>
                <artifactId>jackson-dataformat-csv</artifactId>
                <version>${jackson.version}</version>
            </dependency>

            <!-- camel -->
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-core</artifactId>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-jms</artifactId>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-spring</artifactId>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-quartz2</artifactId>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-jackson</artifactId>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-jaxb</artifactId>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-univocity-parsers</artifactId>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-http4</artifactId>
                <version>${camel.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.geronimo.specs</groupId>
                        <artifactId>geronimo-servlet_3.0_spec</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

            <!-- Logging -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl-over-slf4j</artifactId>
                <version>${slf4j.version}</version>
                <scope>runtime</scope>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>${slf4j.version}</version>
                <scope>runtime</scope>
            </dependency>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>${log4j.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>javax.mail</groupId>
                        <artifactId>mail</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>javax.jms</groupId>
                        <artifactId>jms</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.sun.jdmk</groupId>
                        <artifactId>jmxtools</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.sun.jmx</groupId>
                        <artifactId>jmxri</artifactId>
                    </exclusion>
                </exclusions>
                <scope>runtime</scope>
            </dependency>

            <!-- Tools -->
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>

            <!-- Joda time -->
            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>${joda.time.version}</version>
            </dependency>

            <!-- JAXB -->
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>${jaxb.api.version}</version>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
                <version>${jaxb.sun.version}</version>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-core</artifactId>
                <version>${jaxb.sun.version}</version>
            </dependency>

            <dependency>
                <groupId>org.ocpsoft.prettytime</groupId>
                <artifactId>prettytime</artifactId>
                <version>${prettytime.version}</version>
            </dependency>

            <!-- Apache HttpClient -->
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>${httpclient.version}</version>
            </dependency>

            <!-- Conversion -->
            <dependency>
                <groupId>net.sf.dozer</groupId>
                <artifactId>dozer</artifactId>
                <version>${dozer.version}</version>
            </dependency>

            <!-- Spring security -->
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-web</artifactId>
                <version>${spring.security.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-config</artifactId>
                <version>${spring.security.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-core</artifactId>
                <version>${spring.security.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-taglibs</artifactId>
                <version>${spring.security.version}</version>
            </dependency>

            <!-- Servlet -->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>${javax.servlet}</version>
                <scope>provided</scope>
            </dependency>

            <!-- jsoup HTML parser library @ http://jsoup.org/ -->
            <dependency>
                <groupId>org.jsoup</groupId>
                <artifactId>jsoup</artifactId>
                <version>${jsoup.version}</version>
            </dependency>

            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>${commons.io.version}</version>
            </dependency>

            <!-- Elasticsearch -->
            <dependency>
                <groupId>org.elasticsearch.client</groupId>
                <artifactId>transport</artifactId>
                <version>${elastic.search.version}</version>
            </dependency>

            <!-- Test -->
            <dependency>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-all</artifactId>
                <version>${hamcrest.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-all</artifactId>
                <version>${mockito.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.easytesting</groupId>
                <artifactId>fest-assert</artifactId>
                <version>${easytesting.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${spring.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.camel</groupId>
                <artifactId>camel-test-spring</artifactId>
                <version>${camel.version}</version>
            </dependency>
            <dependency>
                <groupId>org.spockframework</groupId>
                <artifactId>spock-spring</artifactId>
                <version>${spock.version}</version>
            </dependency>
            <!-- groovy -->
            <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-all</artifactId>
                <version>${groovy.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.spockframework</groupId>
                <artifactId>spock-maven</artifactId>
                <version>${spock.version}</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>cglib</groupId>
                <artifactId>cglib</artifactId>
                <version>${cglib.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.tomcat</groupId>
                <artifactId>tomcat-catalina</artifactId>
                <version>${tomcat.version}</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

1 个答案:

答案 0 :(得分:4)

spring-data-elasticsearch:2.0.5.RELEASE尚不支持Elasticsearch 5.x 这是一项正在进行的工作,请参阅https://github.com/spring-projects/spring-data-elasticsearch/pull/162