gpt4 book ai didi

java - Spring Boot + ReactiveCosmosRepository + java.lang.NoSuchMethodError : reactor. util.concurrent.Queues.empty()Ljava/util/function/Supplier

转载 作者:行者123 更新时间:2023-12-02 08:59:54 29 4
gpt4 key购买 nike

我正在 Spring Boot 项目中实现 Cosmos DB,但在连接到 Azure Cosmos DB 时遇到错误。

POM.xml

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-cosmosdb-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-data-cosmosdb</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb</artifactId>
<version>2.4.6</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>

存储库

package com.staples.ctg.repository.cosmos;

import org.springframework.stereotype.Repository;

import com.microsoft.azure.spring.data.cosmosdb.repository.ReactiveCosmosRepository;
import com.staples.ctg.service.dto.cache.GenericCacheDTO;


@Repository
public interface SpotCacheRepository extends ReactiveCosmosRepository <GenericCacheDTO, String> {

}

applicationProperties.yml

azure:        

cosmosdb:

uri: Cosmos URI

key: Key

database: DB Name that I created

DTO

package com.staples.ctg.service.dto.cache;

@Document(collection="cosmos")
public class GenericCacheDTO {
@Id
private String id;
@PartitionKey
private String accountId;

}

当我在本地启动时,出现以下错误

2020-02-14 12:20:32.922  INFO 22777 --- [  restartedMain] c.a.d.c.internal.RxDocumentClientImpl    : Initializing DocumentClient with serviceEndpoint [<Azure Cosmos URI>], connectionPolicy [ConnectionPolicy{requestTimeoutInMillis=60000, mediaRequestTimeoutInMillis=300000, connectionMode=DIRECT, maxPoolSize=1000, idleConnectionTimeoutInMillis=60000, userAgentSuffix=';spring-data/2.2.0;8d0607104487ba8c93ae7a32c5e20645d1bb21edf269625ead71da72d4877d65;', retryOptions=RetryOptions{maxRetryAttemptsOnThrottledRequests=9, maxRetryWaitTimeInSeconds=30}, enableEndpointDiscovery=true, preferredLocations=null, usingMultipleWriteLocations=false, inetSocketProxyAddress=null}], consistencyLevel [null], directModeProtocol [Tcp]
2020-02-14 12:20:32.922 DEBUG 22777 --- [ restartedMain] reactor.util.Loggers$LoggerFactory : Using Slf4j logging framework
2020-02-14 12:20:32.979 DEBUG 22777 --- [ restartedMain] c.a.d.c.internal.GlobalEndpointManager : registering a refresh in [300000] ms
2020-02-14 12:20:33.034 DEBUG 22777 --- [ parallel-1] c.a.d.c.internal.GlobalEndpointManager : startRefreshLocationTimerAsync() - Invoking refresh, I was registered on [2020-02-14T12:20:32.985]
2020-02-14 12:20:33.035 INFO 22777 --- [ parallel-1] c.a.d.c.internal.RxDocumentClientImpl : Getting database account endpoint from https:<Azure Cosmos URI>
2020-02-14 12:20:33.123 DEBUG 22777 --- [ parallel-1] reactor.netty.tcp.TcpResources : [http] resources will use the default LoopResources: DefaultLoopResources {prefix=reactor-http, daemon=true, selectCount=8, workerCount=8}
2020-02-14 12:20:33.123 DEBUG 22777 --- [ parallel-1] reactor.netty.tcp.TcpResources : [http] resources will use the default ConnectionProvider: PooledConnectionProvider {name=http, poolFactory=reactor.netty.resources.ConnectionProvider$$Lambda$2068/965477132@65222f44}
2020-02-14 12:20:33.130 DEBUG 22777 --- [ parallel-1] r.netty.resources.DefaultLoopEpoll : Default Epoll support : false
2020-02-14 12:20:33.132 DEBUG 22777 --- [ parallel-1] r.netty.resources.DefaultLoopKQueue : Default KQueue support : false
2020-02-14 12:20:33.162 DEBUG 22777 --- [ parallel-1] r.n.resources.PooledConnectionProvider : Creating new client pool [reactor-netty-connection-pool] for <Azure Cosmos URI>
2020-02-14 12:20:33.183 ERROR 22777 --- [ parallel-1] reactor.core.scheduler.Schedulers : Scheduler worker in group main failed with an uncaught exception

java.lang.NoSuchMethodError: reactor.util.concurrent.Queues.empty()Ljava/util/function/Supplier;
at reactor.netty.internal.shaded.reactor.pool.SimpleFifoPool.<clinit>(SimpleFifoPool.java:35)
at reactor.netty.internal.shaded.reactor.pool.PoolBuilder.build(PoolBuilder.java:333)
at reactor.netty.internal.shaded.reactor.pool.PoolBuilder.fifo(PoolBuilder.java:321)
at reactor.netty.resources.ConnectionProvider.lambda$fixed$3(ConnectionProvider.java:197)
at reactor.netty.resources.PooledConnectionProvider$PooledConnectionAllocator.<init>(PooledConnectionProvider.java:237)
at reactor.netty.resources.PooledConnectionProvider.lambda$acquire$2(PooledConnectionProvider.java:154)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at reactor.netty.resources.PooledConnectionProvider.lambda$acquire$3(PooledConnectionProvider.java:148)
at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:54)
at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.lambda$subscribe$0(HttpClientConnect.java:319)
at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:54)
at reactor.core.publisher.Mono.subscribe(Mono.java:3088)
at reactor.core.publisher.FluxRetryPredicate$RetryPredicateSubscriber.resubscribe(FluxRetryPredicate.java:123)
at reactor.core.publisher.MonoRetryPredicate.subscribe(MonoRetryPredicate.java:51)
at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect.subscribe(HttpClientConnect.java:322)
at reactor.core.publisher.MonoFlatMapMany.subscribe(MonoFlatMapMany.java:49)
at reactor.core.publisher.MonoSingle.subscribe(MonoSingle.java:58)
at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
at reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)
at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
at reactor.core.publisher.FluxSourceMono.subscribe(FluxSourceMono.java:46)
at reactor.core.publisher.MonoSingle.subscribe(MonoSingle.java:58)
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:53)
at reactor.core.publisher.Mono.subscribe(Mono.java:3088)
at reactor.core.publisher.FluxRetryWhen.subscribe(FluxRetryWhen.java:82)
at reactor.core.publisher.MonoRetryWhen.subscribe(MonoRetryWhen.java:50)
at reactor.core.publisher.FluxSourceMono.subscribe(FluxSourceMono.java:46)
at reactor.core.publisher.FluxOnErrorResume.subscribe(FluxOnErrorResume.java:47)
at reactor.core.publisher.FluxMap.subscribe(FluxMap.java:62)
at reactor.core.publisher.FluxPeek.subscribe(FluxPeek.java:83)
at reactor.core.publisher.FluxMap.subscribe(FluxMap.java:62)
at reactor.core.publisher.FluxPeek.subscribe(FluxPeek.java:83)
at reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:55)
at reactor.core.publisher.FluxPeek.subscribe(FluxPeek.java:83)
at reactor.core.publisher.MonoSingle.subscribe(MonoSingle.java:58)
at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
at reactor.core.publisher.MonoDelay$MonoDelayRunnable.run(MonoDelay.java:117)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50)
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

2020-02-14 12:20:46.801 WARN 22777 --- [scoveryClient-1] c.netflix.discovery.TimedSupervisorTask : task supervisor timed out

java.util.concurrent.TimeoutException: null

最佳答案

这看起来像是 react 堆核心版本不正确的问题。

此依赖项可能会带来旧版本的reactor-core。

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-cosmosdb-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>

解决此问题的两种方法:

  1. 尝试从这种依赖关系中排除reactor-core。

  2. 尝试添加reactor-core依赖项 - 3.3.0或更高版本。

关于java - Spring Boot + ReactiveCosmosRepository + java.lang.NoSuchMethodError : reactor. util.concurrent.Queues.empty()Ljava/util/function/Supplier,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60246812/

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