我一直认为Session.run需要输入图中的所有占位符,而Session.partial_run只输入通过 指定的占位符Session.partial_run_setup,但进一步看情况并非如此。
那么这两种方法究竟如何区分呢?使用其中一种的优点/缺点是什么?
一般来说,我对 Webflux 和 Spring 很陌生,并且在设置处理 POST 请求的简单服务器时遇到了麻烦:
WebfluxtestApplication.java
package com.test.webfluxtest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
@SpringBootApplication
@RestController
public class WebfluxtestApplication {
public static void main(String[] args) {
SpringApplication.run(WebfluxtestApplication.class, args);
}
@PostMapping
public Mono<Person> processPerson(@RequestBody Mono<Person> personMono){
Person person = personMono.block();
person.setAge(42);
return Mono.just(person);
}
}
Run Code Online (Sandbox Code Playgroud)
如下Person:
人.java
package com.test.webfluxtest;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Person {
private String name;
private int age;
public Person(@JsonProperty String name, @JsonProperty int age){
this.name = name; …Run Code Online (Sandbox Code Playgroud)