NoSuchMethodError: org.springframework.data.util.TypeInformation.isSubTypeOf (Ljava / lang / Class;) Z - PullRequest
0 голосов
/ 17 февраля 2020

Я использую Spring Data Elasticsearch с Elasticsearch версии 7.4. Maven:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        <version>2.1.7.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
        <version>4.0.0.BUILD-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-commons</artifactId>
        <version>2.1.10.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>7.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>7.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-client</artifactId>
        <version>7.4.0</version>
    </dependency>

Модель

@AllArgsConstructor
@NoArgsConstructor
@Data
@Document(indexName = "address", createIndex = true)
public class Address {
    @Id
    private String id;
    private String fullAddress;

    @Field(type = FieldType.Nested, store = true)
    private List<Entry> parts;

    public Address(String fullAddress) {
        this.fullAddress = fullAddress;
    }

    public Address(String fullAddress, List<Entry> entryList) {
        this.fullAddress = fullAddress;
        this.parts = entryList;
    }
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Entry {
    private String aoid;
    private String aoGuid;
    private String code;
    private String offName;
    private String parentGuid;
    private String shortName;
    @Field(type = FieldType.Integer)
    private Integer aoLevel;
    private String postalCode;
}

Репозиторий:

@Repository
public interface AddressElasticRepository extends ElasticsearchRepository<Address, String> {
    List<Address> findByFullAddressContains(String fullAddress);
}

Сервис

@Service
public class SearchServiceImpl implements SearchService {
    private final AddressElasticRepository addressElasticRepository;

    public SearchServiceImpl(AddressElasticRepository addressElasticRepository) {
        this.addressElasticRepository = addressElasticRepository;
    }

    @Override
    public List<Document> search(String query) {
        List<Address> all = addressElasticRepository.findByFullAddressContains(query);
        all.forEach(it -> log.info("-- " + it.getFullAddress()));

        return null;
    }

    @Override
    public void save(Address address) {
        addressElasticRepository.save(address);
    }
}

Контроллер:

@Controller
public class SearchController {
    private final SearchService searchService;

    public SearchController(SearchService searchService) {
        this.searchService = searchService;
    }

    @RequestMapping(value = "/api/v1/fias/search", method = GET)
    public List<Document> search(@RequestParam String query) {
        return searchService.search(query);
    }
}

Когда я выполняю поиск: localhost: 8189 / api / v1 / fias / search? Query = Moscow Я получаю сообщение об ошибке:

java .lang. NoSuchMethodError: org.springframework.data.util.TypeInformation.isSubTypeOf (Ljava / lang / Class;) Z

Ошибка в строке ( SearchServiceImpl. java: 23 ): Список всех = addressElasticRepository.findByFullAddressContains (запрос);

Как это исправить?

UPD: Full StackTrace

java .lang.NoSuchMethodError: org.springframework.data.util.TypeInformation.isSubTypeOf (Ljava / lang / Class;) Z в org.springframework.data.elasticsearch.core.conl. MappingElasticsearchConverter. java: 675) ~ [spring-data -asticsearch-4.0.0.BUILD-20200217.043541-321.jar: 4.0.0.BUILD-SNAPSHOT] в org.springframework.d ata.elasticsearch.core.convert. .springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.readValue (MappingElasticsearchConverter. java: 345) ~ [spring-data -asticsearch-4.0.0.BUILD-20200217.043541-321.jar: 4.0.0.BUILD-SNA ] at org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter $ ElasticsearchPropertyValueProvider.getPropertyValue (MappingElasticsearchConverter. java: 876) ~ [spring-data -asticsearch-4.0.01.7.04: 2041200200 0.BUILD-SNAPSHOT] в org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.readProperties (MappingElasticsearchConverter. java: 319) ~ [spring-data -asticsearch-4.0.0.BUILD-20200217jar3541- : 4.0.0.BUILD-SNAPSHOT] at org.springframework.data.elasticsearch.core.convert.MappingElasticsearch Converter.readEntity (MappingElasticsearchConverter. java: 267) ~ [spring-data -asticsearch-4.0.0.BUILD-20200217.043541-321.jar: 4.0.0.BUILD-SNAPSHOT] на org.springframework.data.elasticsearch.core .convert.MappingElasticsearchConverter.read (MappingElasticsearchConverter. java: 247) ~ [spring-data -asticsearch-4.0.0.BUILD-20200217.043541-321.jar: 4.0.0.BUILD-SNAPSHOT] в org.springframework.data. asticsearch.core.convert. .data.elasticsearch.core.convert.MappingElasticsearchConverter.read (MappingElasticsearchConverter. java: 188) ~ [spring-data -asticsearch-4.0.0.BUILD-20200217.043541-321.jar: 4.0.0.BUILD-SNAPSHOT] в org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter.lambda $ read $ 1 (MappingElasticsearchConverter. java: 169) ~ [spring-data-эластичный поиск-4.0.0.BUILD-20200217. 043541-321.jar: 4.0.0.BUILD-SNAPSHOT] в java .util.stream.ReferencePipeline $ 3 $ 1.accept (ReferencePipeline. java: 193) ~ [na: 1.8.0_201] в java. util.ArrayList $ ArrayListSpliterator.forEachRemaining (ArrayList. java: 1382) ~ [na: 1.8.0_201] в java .util.stream.AbstractPipeline.copyInto (AbstractPipeline. java: 481) ~ [na: 1.8 .0_201] в java .util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline. java: 471) ~ [na: 1.8.0_201] в java .util.stream.ReduceOps $ ReduceOp.evaluateSequential (ReduceOps. java: 708) ~ [na: 1.8.0_201] в java .util.stream.AbstractPipeline.evaluate (AbstractPipeline. java: 234) ~ [na: 1.8.0_201] в java .util.stream .ReferencePipeline.collect (ReferencePipeline. java: 499) ~ [na: 1.8.0_201] в org.springframework.data.elasticsearch. core.convert.MappingElasticsearchConverter.read (MappingElasticsearchConverter. java: 170) ~ [spring-data -asticsearch-4.0.0.BUILD-20200217.043541-321.jar: 4.0.0.BUILD-SNAPSHOT] в org.springframework.data .elasticsearch.core.ElasticsearchRestTemplate.search (ElasticsearchRestTemplate. java: 244) ~ [spring-data -asticsearch-4.0.0.BUILD-20200217.043541-321.jar: 4.0.0.BUILD-SNAPSHOT] в org.springframework. data.elasticsearch.repository.query.ElasticsearchPartQuery.execute (ElasticsearchPartQuery. java: 106) ~ [spring-data -asticsearch-4.0.0.BUILD-20200217.043541-321.jar: 4.0.0.BUILD-SNAPSHOT] в организации .springframework.data.repository.core.support.RepositoryFactorySupport $ QueryExecutorMethodInterceptor.doInvoke (RepositoryFactorySupport. java: 605) ~ [spring-data-commons-2.1.10.RELEASE.jar: 2.1.10.gr. springframework.data.repository.core.support.RepositoryFactorySupport $ QueryExecutorMethodInterceptor.lambda $ invoke $ 3 (RepositoryFactorySupport. java: 595) ~ [spring-data-commons-2.1.10.RELEASE. jar: 2.1.10.RELEASE] at org.springframework.data.repository.core.support.RepositoryFactorySupport $ QueryExecutorMethodInterceptor.invoke (RepositoryFactorySupport. java: 595) ~ [spring-data-commonsE 2.1.10.jar. : 2.1.10.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation. java: 185) ~ [spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org .springframework.data. ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation. java: 185) ~ [spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.aop.interceptor.ExposeInvocationInterceptor.invocation : 92) ~ [spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation. java: 185) ~ [spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke (SurroundingTransactionDetectorMethod ~89] -data-commons-2.1.10.RELEASE.jar: 2.1.10.RELEASE] в org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation. java: 185) ~ [spring-aop-5.0.4. RELEASE.jar: 5.0.4.RELEASE] в org.springframework.aop.framework.JdkDynamicAopProxy.invoke (JdkDynamicAopProxy. java: 212) ~ [spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE ] at com.sun.proxy. $ Proxy120.findByFullAddressContains (неизвестный источник) ~ [na: na] at sun.reflect.NativeMethodAccessorImpl.invoke0 (собственный метод) ~ [na: 1.8.0_201] at sun.reflect.NativeMethodAccessorImpl.inke (NativeMethodAccessorImpl. java: 62) ~ [na: 1.8.0_201] at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl. java: 43) ~ [na: 1.8.0_201] в java .lang.reflect .Metod.invoke (Method. java: 498) ~ [na: 1.8.0 _201] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (AopUtils. java: 338) ~ [spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE] на org.springframework.aop. framework.ReflectiveMethodInvocation.invokeJoinpoint (ReflectiveMethodInvocation. java: 197) ~ [spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.aop.framework.ReflectiveMethodocd. 1098 *: 163) ~ [spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke (PersistenceExceptionTranslationInterceptor. java: 139) ~ [spring- tx-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation. java: 185) ~ [spring-aop-5.0.4.RELEASE.jar : 5.0.4.RELEASE] на org.springframework.aop. framework.JdkDynamicAopProxy.invoke (JdkDynamicAopProxy. java: 212) ~ [spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в com.sun.proxy. $ Proxy120.findByFullAddressContains (неизвестный источник) ~ [na: na] на ru.evolenta.server.service.impl.SearchServiceImpl.search ( SearchServiceImpl. java: 23 ) ~ [классы /: na] на ru.evolenta.server.controller. SearchController.search ( SearchController. java: 27 ) ~ [classes /: na] в sun.reflect.NativeMethodAccessorImpl.invoke0 (собственный метод) ~ [na: 1.8.0_201] в sun.reflect. NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl. java: 62) ~ [na: 1.8.0_201] в sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl. java: 43) ~] при 1.8: lang.reflect.Method.invoke (Method. java: 498) ~ [na: 1.8.0_201] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke (InvocableHandlerMethod. java: 209) ~ [весна] -web-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.web.method.support.InvocableHandlerMethod.invo keForRequest (InvocableHandlerMethod. java: 136) ~ [spring-web-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.web.servlet. mvc .method.annotation.ServletInvocableHandlerMethodin. (ServletInvocableHandlerMethod. java: 102) ~ [spring-web mvc -5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.web.servlet. mvc .method.annotation.RequestMappingHandlerAdapter .invokeHandlerMethod (RequestMappingHandlerAdapter. java: 870) ~ [spring-web mvc -5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.web.servlet. mvc .method.annotation .RequestMappingHandlerAdapter.handleInternal (RequestMappingHandlerAdapter. java: 776) ~ [spring-web mvc -5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.web.servlet. mvc .method .AbstractHandlerMethodAdapter.handle (AbstractHandlerMethodAdapter. java: 87) ~ [spring-web mvc -5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.web.servlet.DispatcherServlet.doDisper . java: 991) ~ [spring-web mvc -5.0.4.RELEASE.jar : 5.0.4.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet. java: 925) ~ [spring-web mvc -5.0.4.RELEASE.jar: 5.0.4.RELEASE ] в org.springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet. java: 978) ~ [spring-web mvc -5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework. web.servlet.FrameworkServlet.doGet (FrameworkServlet. java: 870) ~ [spring-web mvc -5.0.4.RELEASE.jar: 5.0.4.RELEASE] в javax.servlet.http.HttpServlet.service ( HttpServlet. java: 635) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet. java: 855) ~ [spring -web mvc -5.0.4.RELEASE.jar: 5.0.4.RELEASE] по адресу javax.servlet.http.HttpServlet.service (HttpServlet. java: 742) ~ [tomcat-embed-core-8.5.28 .jar: 8.5.28] at org. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 231) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в org . apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] at org. apache .tomcat.websocket.server.WsFilter.doFilter (WsFilter. java): 52) ~ [tomcat-embed-websocket-8.5.28.jar: 8.5.28] в орг. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) ~ [tomcat-embed-core -8.5.28.jar: 8.5.28] в орг. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed-core-8.5.28.jar: 8.5. 28] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics (WebMvcMetricsFilter. java: 158) ~ [spring-boot-activator-2.0.0.RELEASE.jar: 2.0.0.EL ] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics (WebMvcMetricsFilter. java: 126) ~ [spring-boot-activator-2.0.0.RELEASE.jar: 2.0.0. RELEASE] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal (WebMvcMetricsFilter. java: 111) ~ [spring-boot-activator-2.0.0.RELEASE.jar: 2.0.0.RELE ] at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 107) ~ [spring-web-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в орг. apache .catalina .core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] at org. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal (HttpTraceFilter. java: 84 ) ~ [spring-boot-activator-2.0.0.RELEASE.jar: 2.0.0.RELEASE] в org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 107) ~ [spring-web- 5.0.4.RELEASE.jar: 5.0.4.RELEASE] at org. apache .catalina.core.ApplicationFilterChain.internalDoFilter (Applicatio nFilterChain. java: 193) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] at org. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] на ru.evolenta.server.filters.SimpleCORSFilter.doFilter (SimpleCORSFilter. java: 51) ~ [classes /: na] в орг. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в орг. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (CharacterEncodingFilter. java: 200) ~ [ spring-web-5.0.4.RELEASE.jar: 5.0.4.RELEASE] по адресу org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 107) ~ [spring-web-5.0.4.RELEASE .jar: 5.0.4.RELEASE] at org. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) ~ [tomcat-embed-core-8.5. 28.jar: 8.5.28] at org. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в org.springframework.security.web.FilterChainProxy.doFilterInternal (FilterChainProxy. java: 209) ~ [spring-security-web-5.0.3.RELEASE.jar: 5.0.3.RELEASE] в org.springframework.security.web .FilterChainProxy.doFilter (FilterChainProxy. java: 178) ~ [spring-security-web-5.0.3.RELEASE.jar: 5.0.3.RELEASE] в org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate (DelegatingFilterPro. java: 357) ~ [spring-web-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.web.filter.DelegatingFilterProxy.doFilter (DelegatingFilterProxy. java: 270) ~ [spring -web-5.0.4.RELEASE.jar: 5.0.4.RELEASE] at org. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) ~ [tomcat-embed-core-8.5. 28.jar: 8.5.28] at org. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed-cor e-8.5.28.jar: 8.5.28] at org.springframework.web.filter.RequestContextFilter.doFilterInternal (RequestContextFilter. java: 99) ~ [spring-web-5.0.4.RELEASE.jar: 5.0.4 .RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 107) ~ [spring-web-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в организации. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в орг. apache .catalina.core.ApplicationFilterChain.doFilter ( ApplicationFilterChain. java: 166) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal (HttpPutFormContentFilter. java: 109 ~ [spring] -web-5.0.4.RELEASE.jar: 5.0.4.RELEASE] по адресу org.springframework.web.filter.OncePerRequestFilter. doFilter (OncePerRequestFilter. java: 107) ~ [spring-web-5.0.4.RELEASE.jar: 5.0.4.RELEASE] at org. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java) : 193) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в орг. apache .catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain. java: 166) ~ [tomcat-embed- core-8.5.28.jar: 8.5.28] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal (HiddenHttpMethodFilter. java: 81) ~ [spring-web-5.0.4.RELEASE.jar: 5.0.4 .RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter (OncePerRequestFilter. java: 107) ~ [spring-web-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в организации. apache .catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain. java: 193) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в орг. apache .catalina.core.ApplicationFilterChain.doFilter ( ApplicationFilterChain. java: 166) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в org. apache .catalina.core.StandardWrapperValve.invoke (Стандарт dWrapperValve. java: 199) ~ [tomcat-embed-core-8.5.28.jar: 8.5.28] в org. apache .catalina.core.StandardContextValve.invoke (StandardContextValve. java: 96) [ tomcat-embed-core-8.5.28.jar: 8.5.28] at org. apache .catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase. java: 496) [tomcat-embed-core-8.5.28. jar: 8.5.28] в org. apache .catalina.core.StandardHostValve.invoke (StandardHostValve. java: 140) [tomcat-embed-core-8.5.28.jar: 8.5.28] в org. apache .catalina.valves.ErrorReportValve.invoke (ErrorReportValve. java: 81) [tomcat-embed-core-8.5.28.jar: 8.5.28] в орг. apache .catalina.core.StandardEngineValve.invoke (StandardEngineValve. java: 87) [tomcat-embed-core-8.5.28.jar: 8.5.28] at org. apache .catalina.connector.CoyoteAdapter.service (CoyoteAdapter. java: 342) [ tomcat-embed-core-8.5.28.jar: 8.5.28] at org. apache .coyote.http11.Http11Processor.service (Http11Processor. java: 803) [tomcat-embed-core-8.5.28. jar: 8.5.28] at org. apache .coyote.AbstractProcessorLight.process (AbstractProcessorLight. * 1 212 *: 66) [tomcat-embed-core-8.5.28.jar: 8.5.28] at org. apache .coyote.AbstractProtocol $ ConnectionHandler.process (AbstractProtocol. java: 790) [tomcat-embed- core-8.5.28.jar: 8.5.28] at org. apache .tomcat.util. net .NioEndpoint $ SocketProcessor.doRun (NioEndpoint. java: 1459) [tomcat-embed-core-8.5. 28.jar: 8.5.28] at org. apache .tomcat.util. net .SocketProcessorBase.run (SocketProcessorBase. java: 49) [tomcat-embed-core-8.5.28.jar: 8.5. 28] в java .util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor. java: 1149) [na: 1.8.0_201] в java .util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor. java : 624) [na: 1.8.0_201] в орг. apache .tomcat.util.threads.TaskThread $ WrappingRunnable.run (TaskThread. java: 61) [tomcat-embed-core-8.5.28.jar: 8.5.28] at java .lang.Thread.run (Thread. java: 748) [na: 1.8.0_201]

UPD 2 : ошибка в Spring-Data-Commons версия. Метод isSubTypeOf появился после версии 2.2. Если я обновляюсь, приложение не запускается, вот трассировка стека:

java .lang.NoSuchFieldError: IMPORT_BEAN_NAME_GENERATOR в org.springframework.data.repository.config.RepositoryBeanDefinitionPeportReeBeportReeWeReист . java: 78) ~ [spring-data-commons-2.2.1.RELEASE.jar: 2.2.1.RELEASE] в org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda $ loadBeanDefinitionsFromRegistrars $ 0 (ConfigurationClassBeader) 12 $. : 360) ~ [spring-context-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в java .util.LinkedHashMap.forEach (LinkedHashMap. java: 684) ~ [na: 1.8.0_201] в org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars (ConfigurationClassBeanDefinitionReader. java: 359) ~ [spring-context-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass (ConfigurationClassBeanDefinitionReader. java: 144) [весна] [5.0.4] .RELEASE.jar: 5.0.4.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions (ConfigurationClassBeanDefinitionReader. java: 117) ~ [spring-context-5.0.4.RELEASE.jar. RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions (ConfigurationClassPostProcessor. java: 328) ~ [spring-context-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springrara. annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry (ConfigurationClassPostProcessor. java: 233) ~ [spring-context-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.context.support.PostProegnRegenceRecessingRegateReGate sorRegistrationDelegate. java: 273) ~ [spring-context-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors (PostProcesslegRegaters) 12 Postgroup. [spring-context-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors (AbstractApplicationContext. java: 693) ~ [spring-context-5.0.4. RELEASE.jar: 5.0.4.RELEASE] в org.springframework.context.support.AbstractApplicationContext.refre sh (AbstractApplicationContext. java: 531) ~ [spring-context-5.0.4.RELEASE.jar: 5.0. 4.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refre sh (ServletWebServerApplicationContext. java: 140) ~ [spring-boot-2.0.0.RELEASE.jar: 2.0.0. RELEASE] в org.springframework.boot.SpringApplication.refre sh (SpringApplication. java: 752) [spring-boot-2.0.0.RELEASE.jar: 2.0.0.RELEASE] в org.springframework.boot. SpringApp lication.refreshContext (SpringApplication. java: 388) [spring-boot-2.0.0.RELEASE.jar: 2.0.0.RELEASE] в org.springframework.boot.SpringApplication.run (SpringApplication. java: 327) [spring-boot-2.0.0.RELEASE.jar: 2.0.0.RELEASE] в org.springframework.boot.SpringApplication.run (SpringApplication. java: 1246) [spring-boot-2.0.0.RELEASE.jar : 2.0.0.RELEASE] в org.springframework.boot.SpringApplication.run (SpringApplication. java: 1234) [spring-boot-2.0.0.RELEASE.jar: 2.0.0.RELEASE] в ru.evolenta. server.CoreFiasApplication.main (CoreFiasApplication. java: 21) [классы /: na]

Ответы [ 3 ]

1 голос
/ 17 февраля 2020

Spring Data Elasticsearch 4.0.0.BUILD-SNAPSHOT построен на основе Spring Data Commons 2.3.0.BUILD-SNAPSHOT. Вы не должны использовать более старые общежития 2.1.10. ВЫПУСКАЙТЕ здесь.

Из любопытства: почему вы используете CustomElasticSearchConverter?

Что касается конфигурации, отметьте https://docs.spring.io/spring-data/elasticsearch/docs/4.0.0.M3/reference/html/#elasticsearch .clients.rest .

И при выполнении пользовательской конфигурации

@SpringBootApplication(exclude = {ElasticsearchAutoConfiguration.class})

- правильный путь к go.

Редактировать:

spring-data -asticsearch 4.0.0.BUILD_SNAPSHOT не будет работать с пружинными data-commons 2.0.5. RepositoryBeanDefinitionRegistrarSupport.IMPORT_BEAN_NAME_GENERATOR был представлен в Spring 5.2.

Таким образом, для spring-data -asticsearch 4.0 нужны пружины data-commons 2.3 и Spring 5.2.3. Отсутствие этих версий приведет к ошибкам, которые вы видите.

0 голосов
/ 17 февраля 2020

@ GiorgiTsiklauri Ваши советы помогли мне прийти к правильному решению. Я внимательно прочитал трассировку стека и изучил зависимости моей версии Spring Boot. В Spring-boot-dependencies-2.0.0.RELEASE.pom перечислены версии 5.6.8 для ElasticSearch (моя версия 7.4). Я переписал свой код в соответствии с этим ответом - { ссылка }. У меня все работало! Мне нужен CustomElasticSearchConverter и ElasticsearchRestTemplate, настроенный с ним.

    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>7.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-high-level-client</artifactId>
        <version>7.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>elasticsearch-rest-client</artifactId>
        <version>7.4.0</version>
    </dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    <version>2.0.0.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-elasticsearch</artifactId>
    <version>4.0.0.BUILD-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-commons</artifactId>
    <version>2.1.10.RELEASE</version>
</dependency>

class CustomElasticSearchConverter extends MappingElasticsearchConverter {

    private CustomConversions conversions = new ElasticsearchCustomConversions(Collections.emptyList());

    CustomElasticSearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) {
        super(mappingContext);
        setConversions(conversions);
    }

    CustomElasticSearchConverter(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext, GenericConversionService conversionService) {
        super(mappingContext, conversionService);
        setConversions(conversions);
    }

    @Override
    protected <R> R readValue(@Nullable Object source, ElasticsearchPersistentProperty property,
                              TypeInformation<R> targetType) {

        if (source == null) {
            return null;
        }

        if (source instanceof List) {
            return readCollectionValue((List) source, property, targetType);
        }

        return super.readValue(source, property, targetType);
    }

    private Object readSimpleValue(@Nullable Object value, TypeInformation<?> targetType) {

        Class<?> target = targetType.getType();

        if (value == null || target == null || ClassUtils.isAssignableValue(target, value)) {
            return value;
        }

        if (conversions.hasCustomReadTarget(value.getClass(), target)) {
            return getConversionService().convert(value, target);
        }

        if (Enum.class.isAssignableFrom(target)) {
            return Enum.valueOf((Class<Enum>) target, value.toString());
        }

        return getConversionService().convert(value, target);
    }


    private <R> R readCollectionValue(@Nullable List<?> source, ElasticsearchPersistentProperty property,
                                      TypeInformation<R> targetType) {

        if (source == null) {
            return null;
        }

        Collection<Object> target = createCollectionForValue(targetType, source.size());

        for (Object value : source) {

            if (isSimpleType(value)) {
                target.add(
                        readSimpleValue(value, targetType.getComponentType() != null ? targetType.getComponentType() : targetType));
            } else {

                if (value instanceof List) {
                    target.add(readValue(value, property, property.getTypeInformation().getActualType()));
                } else {
                    target.add(readEntity(computeGenericValueTypeForRead(property, value), (Map) value));
                }
            }
        }

        return (R) target;
    }

    private Collection<Object> createCollectionForValue(TypeInformation<?> collectionTypeInformation, int size) {

        Class<?> collectionType = collectionTypeInformation.isCollectionLike()//
                ? collectionTypeInformation.getType() //
                : List.class;

        TypeInformation<?> componentType = collectionTypeInformation.getComponentType() != null //
                ? collectionTypeInformation.getComponentType() //
                : ClassTypeInformation.OBJECT;

        return collectionTypeInformation.getType().isArray() //
                ? new ArrayList<>(size) //
                : CollectionFactory.createCollection(collectionType, componentType.getType(), size);
    }

    private ElasticsearchPersistentEntity<?> computeGenericValueTypeForRead(ElasticsearchPersistentProperty property,
                                                                            Object value) {

        return ClassTypeInformation.OBJECT.equals(property.getTypeInformation().getActualType())
                ? getMappingContext().getRequiredPersistentEntity(value.getClass())
                : getMappingContext().getRequiredPersistentEntity(property.getTypeInformation().getActualType());
    }

    private boolean isSimpleType(Object value) {
        return isSimpleType(value.getClass());
    }

    private boolean isSimpleType(Class<?> type) {
        return conversions.isSimpleType(type);
    }
}

Моя конфигурация:

@Bean
RestHighLevelClient elasticsearchClient() {
    return new RestHighLevelClient(RestClient.builder(
            new HttpHost(host, port)
    ));
}

@Primary
@Bean
public ElasticsearchRestTemplate elasticsearchTemplate() {
    CustomElasticSearchConverter converter = new CustomElasticSearchConverter(new SimpleElasticsearchMappingContext(), createConversionService());
    return new ElasticsearchRestTemplate(elasticsearchClient(), converter);
}

private DefaultConversionService createConversionService() {
    return new DefaultConversionService();
}

и средство запуска:

@SpringBootApplication(exclude = {ElasticsearchAutoConfiguration.class})
0 голосов
/ 17 февраля 2020

Я думаю, что проблема в вашем коде:

@Repository
public interface AddressElasticRepository extends ElasticsearchRepository<Address, String> {
    List<Address> findByFullAddressContains(String fullAddress);
}

Попробуйте без Contains и затем с Containing (вместо Contains).

Пожалуйста, см. Spring Data Elasticsearch Создание запроса и Spring Data JPA Создание запроса Документация.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...