gpt4 book ai didi

spring-boot - 我无法在 Spring Boot 中使用 Elasticsearch 实现 Reactive Repository

转载 作者:行者123 更新时间:2023-12-03 00:47:47 25 4
gpt4 key购买 nike

似乎 Elasticsearch 不支持响应式(Reactive)存储库,但我需要尝试其他方式而不是以下两种方式。

方式1 - https://docs.spring.io/spring-data/elasticsearch/docs/current-SNAPSHOT/reference/html/?fbclid=IwAR0fmVRA4NaWBem6sB9vLUsN6s5F3MCF2-10NIVsjQVqqJwrJ0PHrM73co8#elasticsearch.clients

摘要:找不到“ReactiveElasticsearchClient”和“ClientConfiguration”。 (下面的代码进行编辑)

方式2 - https://docs.spring.io/spring-data/elasticsearch/docs/current-SNAPSHOT/reference/html/#elasticsearch.reactive.repositories

摘要:此代码如下。

public interface ReactivePersonRepository extends ReactiveSortingRepository<Person, String> {
Flux<Person> findByFirstname(String firstname);

Flux<Person> findByFirstname(Publisher<String> firstname);

Flux<Person> findByFirstnameOrderByLastname(String firstname);

Flux<Person> findByFirstname(String firstname, Sort sort);

Flux<Person> findByFirstname(String firstname, Pageable page);

Mono<Person> findByFirstnameAndLastname(String firstname, String lastname);

Mono<Person> findFirstByLastname(String lastname);

Mono<Long> countByFirstname(String firstname);

Mono<Boolean> existsByFirstname(String firstname);

Mono<Long> deleteByFirstname(String firstname);
}

org.springframework.dao.InvalidDataAccessApiUsageException: Reactive Repositories are not supported by Elasticsearch. Offending repository is com.example.reactive.repositories.ReactivePersonRepository!
at org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport.useRepositoryConfiguration(RepositoryConfigurationExtensionSupport.java:382) ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]
at org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport.getRepositoryConfigurations(RepositoryConfigurationExtensionSupport.java:104) ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]
at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:145) ~[spring-data-commons-2.1.10.RELEASE.jar:2.1.10.RELEASE]
at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:60) ~[spring-boot-autoconfigure-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$1(ConfigurationClassBeanDefinitionReader.java:364) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[na:na]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:363) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:145) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:327) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at com.example.reactive.ReactiveApplication.main(ReactiveApplication.java:10) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:543) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
2019-09-23 09:43:26.517 DEBUG 4314 --- [ main] onfigReactiveWebServerApplicationContext : Closing org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext@5adba8eb, started on Mon Sep 23 09:43:24 ICT 2019
[WARNING]
java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:543)
at java.lang.Thread.run (Thread.java:834)
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Reactive Repositories are not supported by Elasticsearch. Offending repository is com.example.reactive.repositories.ReactivePersonRepository!
at org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport.useRepositoryConfiguration (RepositoryConfigurationExtensionSupport.java:382)
at org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport.getRepositoryConfigurations (RepositoryConfigurationExtensionSupport.java:104)
at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn (RepositoryConfigurationDelegate.java:145)
at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions (AbstractRepositoryConfigurationSourceSupport.java:60)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$1 (ConfigurationClassBeanDefinitionReader.java:364)
at java.util.LinkedHashMap.forEach (LinkedHashMap.java:684)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars (ConfigurationClassBeanDefinitionReader.java:363)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass (ConfigurationClassBeanDefinitionReader.java:145)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions (ConfigurationClassBeanDefinitionReader.java:117)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions (ConfigurationClassPostProcessor.java:327)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry (ConfigurationClassPostProcessor.java:232)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors (PostProcessorRegistrationDelegate.java:275)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors (PostProcessorRegistrationDelegate.java:95)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors (AbstractApplicationContext.java:705)
at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:531)
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh (ReactiveWebServerApplicationContext.java:66)
at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:744)
at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:391)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:312)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1215)
at org.springframework.boot.SpringApplication.run (SpringApplication.java:1204)
at com.example.reactive.ReactiveApplication.main (ReactiveApplication.java:10)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run (AbstractRunMojo.java:543)
at java.lang.Thread.run (Thread.java:834)
  • 编辑

  • Spring Data Elasticsearch 3.1.10 版和 Elasticsearch 6.8.1 版

    way1的配置

    @Configuration
    public class Config {
    @Bean
    ReactiveElasticsearchClient client() {

    ClientConfiguration clientConfiguration = ClientConfiguration.builder()
    .connectedTo("localhost:9200", "localhost:9291")
    .build();

    return ReactiveRestClients.create(clientConfiguration);
    }
    }

    最佳答案

    响应式(Reactive)存储库接口(interface)在版本 3.2 中可用,目前可从版本 3.2.0.RC3 的里程碑存储库或快照存储库中以 CURRENT-SNAPSHOT 的形式获取文档链接。

    3.2.0.GA 计划于下周的 9 月 30 日 (https://github.com/spring-projects/spring-data-commons/wiki/Release-Train-Moore) 发布,然后将通过普通的 maven 存储库提供。

    Elasticsearch 6.8.1 适用于 Spring Data Elasticsearch 3.2.0.GA

    关于spring-boot - 我无法在 Spring Boot 中使用 Elasticsearch 实现 Reactive Repository,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58073045/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com