While writing a test case for testing a Flux service, I am facing the following error:
java.lang.ClassNotFoundException: reactor.core.scheduler.TimedScheduler
My code is like:
FluxExchangeResult<Event> result = webTestClient.get()
.uri("/events")
.accept(MediaType.TEXT_EVENT_STREAM)
.exchange()
.expectStatus()
.isOk()
.returnResult(Event.class);
Flux<Event> eventFlux = result.getResponseBody();
StepVerifier.create(eventFlux)
.expectNextCount(10)
.expectComplete()
.verify();
I have the following dependencies in the pom:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath />
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.projectreactor</groupId>
<artifactId>reactor-spring</artifactId>
<version>1.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>io.projectreactor.addons</groupId>
<artifactId>reactor-test</artifactId>
<version>3.0.7.RELEASE</version>
</dependency>
Have someone faced and resolved a similar issue? I took a reference from the Dzone article: https://dzone.com/articles/spring-webflux-a-basic-crud-application-part-1
I used a wrong dependency:
<dependency>
<groupId>io.projectreactor.addons</groupId>
<artifactId>reactor-test</artifactId>
<version>3.0.7.RELEASE</version>
</dependency>
The correct one is:
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<version>3.1.0.RELEASE</version>
<scope>test</scope>
</dependency>
The one which appears as the top search for google is probably for some other use.
reactor-test
currently only goes up to 3.0.7.RELEASE
, which includes reactor-core:3.0.7.RELEASE
itself.
You will encounter classes not being found when versions do not match.
Therefore, you can do this
<properties>
<reactor.version>3.0.7.RELEASE</reactor.version>
</properties>
<dependencies>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor.addons</groupId>
<artifactId>reactor-test</artifactId>
<version>${reactor.version}</version>
</dependency>
</dependencies>
However, you might want to start at this documentation to get the latest compatible versions.
尝试删除您的Maven(.m2)存储库并构建agin。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.