如何获得Spring的WebFlux发出响应

b3b456de:

当我创建一个Spring-webflux Web客户端时,我无法使它进入订阅或doOnNext回调。我不断收到此错误:java.lang.IllegalStateException:基础HTTP客户端已完成,没有发出响应。

我尝试在创建webcilent期间更改baseurl。创建Web客户端后尝试了另一个uri。

WebClient build = WebClient.builder().baseUrl("https://www.google.com").build();
Mono<String> t = build.get().uri("/{hi}", "hi").retrieve().bodyToMono(String.class).doOnNext(r->{
    System.out.println("aoeuaotnseuhte");
});

build.get().uri("https://www.google.com").exchange().subscribe(r->{
    System.out.println("aotnsehu this was not a triumph");
});


client.get().uri("/{test}", "test").retrieve().bodyToMono(String.class).subscribe(resp->{
    System.out.println("hai");   
});

client.get().uri("https://github.com/square/okhttp/tree/master/mockwebserver").retrieve().bodyToMono(String.class).subscribe(resp ->{
    System.out.println("hi");
});

我期望断点在所有这些println语句处停止,但我从来没有能够在此停下来。

环境详细信息:Java 1.8.0_144 Spring Boot 2.1.5

控制台输出

"C:\Program Files\Java\jdk1.8.0_144\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:55458,suspend=y,server=n -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\Users\Sam\.IdeaIC2019.1\system\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1\plugins\junit\lib\junit-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1\plugins\junit\lib\junit5-rt.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\rt.jar;C:\Users\Sam\IdeaProjects\wondrous-magic\target\test-classes;C:\Users\Sam\IdeaProjects\wondrous-magic\target\classes;C:\Users\Sam\.m2\repository\org\springframework\boot\spring-boot-starter-webflux\2.1.5.RELEASE\spring-boot-starter-webflux-2.1.5.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\boot\spring-boot-starter\2.1.5.RELEASE\spring-boot-starter-2.1.5.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\boot\spring-boot\2.1.5.RELEASE\spring-boot-2.1.5.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\spring-context\5.1.7.RELEASE\spring-context-5.1.7.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\spring-aop\5.1.7.RELEASE\spring-aop-5.1.7.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\spring-expression\5.1.7.RELEASE\spring-expression-5.1.7.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.1.5.RELEASE\spring-boot-autoconfigure-2.1.5.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.1.5.RELEASE\spring-boot-starter-logging-2.1.5.RELEASE.jar;C:\Users\Sam\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\Sam\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\Sam\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.11.2\log4j-to-slf4j-2.11.2.jar;C:\Users\Sam\.m2\repository\org\apache\logging\log4j\log4j-api\2.11.2\log4j-api-2.11.2.jar;C:\Users\Sam\.m2\repository\org\slf4j\jul-to-slf4j\1.7.26\jul-to-slf4j-1.7.26.jar;C:\Users\Sam\.m2\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;C:\Users\Sam\.m2\repository\org\yaml\snakeyaml\1.23\snakeyaml-1.23.jar;C:\Users\Sam\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.1.5.RELEASE\spring-boot-starter-json-2.1.5.RELEASE.jar;C:\Users\Sam\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.8\jackson-databind-2.9.8.jar;C:\Users\Sam\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;C:\Users\Sam\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.8\jackson-core-2.9.8.jar;C:\Users\Sam\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.8\jackson-datatype-jdk8-2.9.8.jar;C:\Users\Sam\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.8\jackson-datatype-jsr310-2.9.8.jar;C:\Users\Sam\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.8\jackson-module-parameter-names-2.9.8.jar;C:\Users\Sam\.m2\repository\org\springframework\boot\spring-boot-starter-reactor-netty\2.1.5.RELEASE\spring-boot-starter-reactor-netty-2.1.5.RELEASE.jar;C:\Users\Sam\.m2\repository\io\projectreactor\netty\reactor-netty\0.8.8.RELEASE\reactor-netty-0.8.8.RELEASE.jar;C:\Users\Sam\.m2\repository\io\netty\netty-codec-http\4.1.36.Final\netty-codec-http-4.1.36.Final.jar;C:\Users\Sam\.m2\repository\io\netty\netty-common\4.1.36.Final\netty-common-4.1.36.Final.jar;C:\Users\Sam\.m2\repository\io\netty\netty-buffer\4.1.36.Final\netty-buffer-4.1.36.Final.jar;C:\Users\Sam\.m2\repository\io\netty\netty-transport\4.1.36.Final\netty-transport-4.1.36.Final.jar;C:\Users\Sam\.m2\repository\io\netty\netty-resolver\4.1.36.Final\netty-resolver-4.1.36.Final.jar;C:\Users\Sam\.m2\repository\io\netty\netty-codec\4.1.36.Final\netty-codec-4.1.36.Final.jar;C:\Users\Sam\.m2\repository\io\netty\netty-codec-http2\4.1.36.Final\netty-codec-http2-4.1.36.Final.jar;C:\Users\Sam\.m2\repository\io\netty\netty-handler\4.1.36.Final\netty-handler-4.1.36.Final.jar;C:\Users\Sam\.m2\repository\io\netty\netty-handler-proxy\4.1.36.Final\netty-handler-proxy-4.1.36.Final.jar;C:\Users\Sam\.m2\repository\io\netty\netty-codec-socks\4.1.36.Final\netty-codec-socks-4.1.36.Final.jar;C:\Users\Sam\.m2\repository\io\netty\netty-transport-native-epoll\4.1.36.Final\netty-transport-native-epoll-4.1.36.Final-linux-x86_64.jar;C:\Users\Sam\.m2\repository\io\netty\netty-transport-native-unix-common\4.1.36.Final\netty-transport-native-unix-common-4.1.36.Final.jar;C:\Users\Sam\.m2\repository\org\glassfish\javax.el\3.0.0\javax.el-3.0.0.jar;C:\Users\Sam\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.16.Final\hibernate-validator-6.0.16.Final.jar;C:\Users\Sam\.m2\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;C:\Users\Sam\.m2\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;C:\Users\Sam\.m2\repository\com\fasterxml\classmate\1.4.0\classmate-1.4.0.jar;C:\Users\Sam\.m2\repository\org\springframework\spring-web\5.1.7.RELEASE\spring-web-5.1.7.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\spring-beans\5.1.7.RELEASE\spring-beans-5.1.7.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\spring-webflux\5.1.7.RELEASE\spring-webflux-5.1.7.RELEASE.jar;C:\Users\Sam\.m2\repository\io\projectreactor\reactor-core\3.2.9.RELEASE\reactor-core-3.2.9.RELEASE.jar;C:\Users\Sam\.m2\repository\org\reactivestreams\reactive-streams\1.0.2\reactive-streams-1.0.2.jar;C:\Users\Sam\.m2\repository\org\synchronoss\cloud\nio-multipart-parser\1.1.0\nio-multipart-parser-1.1.0.jar;C:\Users\Sam\.m2\repository\org\synchronoss\cloud\nio-stream-storage\1.1.3\nio-stream-storage-1.1.3.jar;C:\Users\Sam\.m2\repository\org\springframework\boot\spring-boot-starter-test\2.1.5.RELEASE\spring-boot-starter-test-2.1.5.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\boot\spring-boot-test\2.1.5.RELEASE\spring-boot-test-2.1.5.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\boot\spring-boot-test-autoconfigure\2.1.5.RELEASE\spring-boot-test-autoconfigure-2.1.5.RELEASE.jar;C:\Users\Sam\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\Sam\.m2\repository\org\assertj\assertj-core\3.11.1\assertj-core-3.11.1.jar;C:\Users\Sam\.m2\repository\org\mockito\mockito-core\2.23.4\mockito-core-2.23.4.jar;C:\Users\Sam\.m2\repository\net\bytebuddy\byte-buddy\1.9.12\byte-buddy-1.9.12.jar;C:\Users\Sam\.m2\repository\net\bytebuddy\byte-buddy-agent\1.9.12\byte-buddy-agent-1.9.12.jar;C:\Users\Sam\.m2\repository\org\objenesis\objenesis\2.6\objenesis-2.6.jar;C:\Users\Sam\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\Sam\.m2\repository\org\hamcrest\hamcrest-library\1.3\hamcrest-library-1.3.jar;C:\Users\Sam\.m2\repository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;C:\Users\Sam\.m2\repository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;C:\Users\Sam\.m2\repository\org\springframework\spring-core\5.1.7.RELEASE\spring-core-5.1.7.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\spring-jcl\5.1.7.RELEASE\spring-jcl-5.1.7.RELEASE.jar;C:\Users\Sam\.m2\repository\org\springframework\spring-test\5.1.7.RELEASE\spring-test-5.1.7.RELEASE.jar;C:\Users\Sam\.m2\repository\org\xmlunit\xmlunit-core\2.6.2\xmlunit-core-2.6.2.jar;C:\Users\Sam\.m2\repository\com\jayway\jsonpath\json-path\2.4.0\json-path-2.4.0.jar;C:\Users\Sam\.m2\repository\net\minidev\json-smart\2.3\json-smart-2.3.jar;C:\Users\Sam\.m2\repository\net\minidev\accessors-smart\1.2\accessors-smart-1.2.jar;C:\Users\Sam\.m2\repository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;C:\Users\Sam\.m2\repository\org\slf4j\slf4j-api\1.7.26\slf4j-api-1.7.26.jar;C:\Users\Sam\.m2\repository\com\squareup\okhttp3\mockwebserver\3.14.1\mockwebserver-3.14.1.jar;C:\Users\Sam\.m2\repository\com\squareup\okhttp3\okhttp\3.14.1\okhttp-3.14.1.jar;C:\Users\Sam\.m2\repository\com\squareup\okio\okio\1.17.2\okio-1.17.2.jar;C:\Users\Sam\.m2\repository\org\jsoup\jsoup\1.11.3\jsoup-1.11.3.jar;C:\Users\Sam\.m2\repository\commons-io\commons-io\2.6\commons-io-2.6.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.spry.magic.service.ApiServiceTest,test
Connected to the target VM, address: '127.0.0.1:55458', transport: 'socket'
23:18:08.515 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
23:18:08.532 [main] DEBUG io.netty.util.internal.PlatformDependent - Platform: Windows
23:18:08.534 [main] DEBUG io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false
23:18:08.534 [main] DEBUG io.netty.util.internal.PlatformDependent0 - Java version: 8
23:18:08.535 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
23:18:08.536 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
23:18:08.536 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
23:18:08.536 [main] DEBUG io.netty.util.internal.PlatformDependent0 - direct buffer constructor: available
23:18:08.537 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true
23:18:08.537 [main] DEBUG io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable prior to Java9
23:18:08.537 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): available
23:18:08.537 [main] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
23:18:08.537 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: C:\Users\Sam\AppData\Local\Temp (java.io.tmpdir)
23:18:08.537 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
23:18:08.539 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: 7621050368 bytes
23:18:08.539 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1
23:18:08.539 [main] DEBUG io.netty.util.internal.CleanerJava6 - java.nio.ByteBuffer.cleaner(): available
23:18:08.540 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
23:18:08.541 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false
23:18:08.541 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false
23:18:08.620 [main] DEBUG io.netty.util.NetUtil - Loopback interface: lo (Software Loopback Interface 1, 127.0.0.1)
23:18:08.620 [main] DEBUG io.netty.util.NetUtil - Failed to get SOMAXCONN from sysctl and file \proc\sys\net\core\somaxconn. Default: 200
23:18:08.623 [main] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
23:18:08.644 [main] DEBUG reactor.netty.tcp.TcpResources - [http] resources will use the default LoopResources: DefaultLoopResources {prefix=reactor-http, daemon=true, selectCount=8, workerCount=8}
23:18:08.644 [main] DEBUG reactor.netty.tcp.TcpResources - [http] resources will use the default ConnectionProvider: PooledConnectionProvider {name=http, poolFactory=reactor.netty.resources.ConnectionProvider$$Lambda$69/511832416@1acaf3d}
23:18:08.758 [main] DEBUG reactor.netty.resources.DefaultLoopEpoll - Default Epoll support : false
23:18:08.758 [main] DEBUG reactor.netty.resources.DefaultLoopKQueue - Default KQueue support : false
23:18:08.763 [main] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 16
23:18:08.807 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024
23:18:08.807 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096
23:18:08.818 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
23:18:08.818 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
23:18:08.830 [main] DEBUG io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available
23:18:51.526 [main] DEBUG org.springframework.web.reactive.function.client.ExchangeFunctions - [4de41af9] HTTP GET https://www.google.com
23:18:51.538 [main] DEBUG io.netty.handler.ssl.OpenSsl - netty-tcnative not in the classpath; OpenSslEngine will be unavailable.
23:18:51.784 [main] DEBUG io.netty.handler.ssl.JdkSslContext - Default protocols (JDK): [TLSv1.2, TLSv1.1, TLSv1] 
23:18:51.784 [main] DEBUG io.netty.handler.ssl.JdkSslContext - Default cipher suites (JDK): [TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA]
23:18:51.814 [main] DEBUG reactor.netty.resources.PooledConnectionProvider - Creating new client pool [http] for www.google.com:443
23:18:51.825 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.processId: 7664 (auto-detected)
23:18:51.908 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.machineId: 30:5a:3a:ff:fe:02:74:f6 (auto-detected)
23:18:51.918 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple
23:18:51.918 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.targetRecords: 4
23:18:51.968 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 16
23:18:51.968 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 16
23:18:51.968 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
23:18:51.969 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11
23:18:51.969 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216
23:18:51.969 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.tinyCacheSize: 512
23:18:51.969 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
23:18:51.969 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
23:18:51.969 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
23:18:51.969 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
23:18:51.969 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimIntervalMillis: 0
23:18:51.969 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.useCacheForAllThreads: true
23:18:51.969 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedByteBuffersPerChunk: 1023
23:18:51.977 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled
23:18:51.977 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0
23:18:51.977 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384
Disconnected from the target VM, address: '127.0.0.1:55458', transport: 'socket'

Process finished with exit code 0

java.lang.IllegalStateException的堆栈跟踪:基础HTTP客户端已完成,没有发出响应。

org.springframework.web.reactive.function.client.DefaultWebClient.<clinit>(DefaultWebClient.java:70)
org.springframework.web.reactive.function.client.DefaultWebClientBuilder.build(DefaultWebClientBuilder.java:212)

编辑:我不正确地使用了webclient,没有执行lambda,因为该程序在返回响应之前退出。像在chas spenlau的答案中那样添加一个块,可以为我解决此问题。chas spenlau的示例对我有用,而当我添加该块时,以上代码示例对我有用。

编辑2:我还需要订阅响应。使用块订阅和块,我可以通过在每个末尾添加.subscribe来修复这些语句。请参阅Thomas的评论以获得更好的解释。

机壳:

我不确定您到底要做什么,所以抱歉,如果这样做没有帮助。但是,当您单击以设置断点时,它应该询问您是希望它位于在线还是lambda上,它是在问您吗?如果是这样,请选择lambda。

在此处输入图片说明

我能够在以下代码中将断点放在该行上,并进入doOnNext内部

               webClient.get()
                .retrieve()
                .bodyToMono(String.class)
                .doOnNext(myString -> {System.out.println(myString);})
                .block();

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用Retrofit2和RxAndroid从Spring WebFlux获得响应

如何使用 Spring Webflux 返回 GZIP 响应?

如何使用 C# 发出 Web 请求并获得响应

如何在Spring WebFlux中记录请求和响应正文

Spring Webflux非阻塞响应

在Spring Webflux中捕获响应

在将响应返回给调用方时,如何注销对Spring WebFlux WebClient请求的失败响应的主体?

如何在Spring Boot中获得完整的HttpServletResponse响应主体?

如何在@WebMvcTest 中获得 Spring Boot 默认验证响应?

如何使用Spring-Hateoas获得HAL格式的响应

Spring WebFlux没有流式响应

如何获得API响应

如何获得XMLHttpRequest的响应?

如何从setnextrequest获得响应:

如何在 Spring webflux 中以字符串形式获取原始响应?

如何在Spring Webflux中返回Mono <Map <String,Flux <Integer >>>响应?

Spring WebFlux - 如何使用 WebClient 将响应打印为字符串而不是对象

响应式编程:Spring WebFlux:如何构建微服务调用链?

如何为基于Webflux的Spring-boot项目在Swagger中添加错误响应格式

无法获得期望的响应,发出发布请求

如何获得HttpUrlConnection的完整响应

如何获得 BatchWriteItem DocumentClient 的响应?

WebException如何获得整体响应?

如何获得curl执行响应

如何获得响应能力?

如何获得NSURLSessionDownloadTask downloadTaskWithRequest的响应

如何获得http请求的响应

如何获得表单响应的价值?

如何计算总执行时间并在响应头中设置Spring WebFlux中每个请求的x-runtime?