我想在springboot中使用最新的reactMongo,但是它发生在MongoClientException上

时间:2019-04-10 08:09:34

标签: java spring spring-boot

当我使用reactMongo测试事务时,我发现它发生了异常。

Mongo的版本是4.0.3,springboot和sprint-boot-reactive-mongo的版本是最新的

com.mongodb.MongoClientException: Sessions are not supported by the MongoDB cluster to which this client is connected
    at com.mongodb.async.client.MongoClientImpl$1.onResult(MongoClientImpl.java:90)
    at com.mongodb.async.client.MongoClientImpl$1.onResult(MongoClientImpl.java:83)
    at com.mongodb.async.client.ClientSessionHelper$2.onResult(ClientSessionHelper.java:80)
    at com.mongodb.async.client.ClientSessionHelper$2.onResult(ClientSessionHelper.java:73)
    at com.mongodb.internal.connection.BaseCluster$ServerSelectionRequest.onResult(BaseCluster.java:433)
    at com.mongodb.internal.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:297)
    at com.mongodb.internal.connection.BaseCluster.selectServerAsync(BaseCluster.java:157)
    at com.mongodb.internal.connection.SingleServerCluster.selectServerAsync(SingleServerCluster.java:41)
    at com.mongodb.async.client.ClientSessionHelper.createClientSession(ClientSessionHelper.java:68)
    at com.mongodb.async.client.MongoClientImpl.startSession(MongoClientImpl.java:83)
    at com.mongodb.reactivestreams.client.internal.MongoClientImpl$1.apply(MongoClientImpl.java:153)
    at com.mongodb.reactivestreams.client.internal.MongoClientImpl$1.apply(MongoClientImpl.java:150)
    at com.mongodb.async.client.SingleResultCallbackSubscription.requestInitialData(SingleResultCallbackSubscription.java:38)
    at com.mongodb.async.client.AbstractSubscription.tryRequestInitialData(AbstractSubscription.java:151)
    at com.mongodb.async.client.AbstractSubscription.request(AbstractSubscription.java:84)
    at com.mongodb.reactivestreams.client.internal.ObservableToPublisher$1$1.request(ObservableToPublisher.java:50)
    at reactor.core.publisher.MonoNext$NextSubscriber.request(MonoNext.java:102)
    at reactor.core.publisher.MonoProcessor.onSubscribe(MonoProcessor.java:399)
    at reactor.core.publisher.MonoNext$NextSubscriber.onSubscribe(MonoNext.java:64)
    at com.mongodb.reactivestreams.client.internal.ObservableToPublisher$1.onSubscribe(ObservableToPublisher.java:39)
    at com.mongodb.async.client.SingleResultCallbackSubscription.<init>(SingleResultCallbackSubscription.java:33)
    at com.mongodb.async.client.Observables$2.subscribe(Observables.java:76)
    at com.mongodb.reactivestreams.client.internal.ObservableToPublisher.subscribe(ObservableToPublisher.java:36)
    at reactor.core.publisher.MonoFromPublisher.subscribe(MonoFromPublisher.java:43)
    at reactor.core.publisher.Mono.subscribe(Mono.java:3694)
    at reactor.core.publisher.MonoProcessor.add(MonoProcessor.java:531)
    at reactor.core.publisher.MonoProcessor.subscribe(MonoProcessor.java:444)
    at reactor.core.publisher.MonoFlatMapMany.subscribe(MonoFlatMapMany.java:49)
    at reactor.core.publisher.Flux.subscribe(Flux.java:7777)
    at reactor.core.publisher.Flux.subscribeWith(Flux.java:7941)
    at reactor.core.publisher.Flux.subscribe(Flux.java:7770)
    at reactor.core.publisher.Flux.subscribe(Flux.java:7734)
    at reactor.core.publisher.Flux.subscribe(Flux.java:7704)
    at com.scy.goodDeed.login.LoginService.testTransaction(LoginService.java:40)
    at com.scy.goodDeed.login.LoginServiceTest.login(LoginServiceTest.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
    at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

请告诉我原因,以及如何解决。

0 个答案:

没有答案