В Spring Web Reactive есть класс WebClient and ClientRequest
. Если мы посмотрим на документацию, то ниже приведен способ использования ClientRequest с помощью WebClient.
WebClient client = WebClient.create(new ReactorClientHttpConnector());
ClientRequest<Void> request = ClientRequest.GET("http://example.com/resource").build();
Mono<String> result = client
.exchange(request)
.then(response -> response.bodyToMono(String.class));
Но, к сожалению, метод ClientRequest.GET недоступен с зависимостью gradle, которую я добавил в свой проект. Ниже приведена зависимость Gradle, которую я использую:
dependencies {
compile('org.springframework.boot.experimental:spring-boot-starter-web-reactive')
compile('org.springframework.cloud:spring-cloud-starter-eureka')
compile('org.springframework.boot:spring-boot-starter-hateoas')
compile('io.reactivex:rxjava')
compile('io.reactivex:rxjava-reactive-streams')
//Spring Test case dependency
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile('io.rest-assured:rest-assured:3.0.1')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Dalston.BUILD-SNAPSHOT"
mavenBom "org.springframework.boot.experimental:spring-boot-dependencies-web-reactive:0.1.0.BUILD-SNAPSHOT"
}
}
Я не смог найти зависимости для M4. Публикуется ли M4 где-нибудь в каком-нибудь репозитории?