Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 如何在不阻塞的情况下从@PathVariable获得Mono_Spring_Spring Boot_Spring Webflux_Project Reactor - Fatal编程技术网

Spring 如何在不阻塞的情况下从@PathVariable获得Mono

Spring 如何在不阻塞的情况下从@PathVariable获得Mono,spring,spring-boot,spring-webflux,project-reactor,Spring,Spring Boot,Spring Webflux,Project Reactor,嗨,我想知道如何在我的控制器中有没有任何阻塞代码转换,从两个参数到DTO类的Mono 假设我有如下控制器: @RestController @所需参数构造函数 类GithubRepositoryEndpoint{ 私人最终GithubService GithubService; @GetMapping(“/repositories/{owner}/{repositoryName}”) Mono getRepositoryDetails(@PathVariable(“所有者”)字符串所有者, @路

嗨,我想知道如何在我的控制器中有没有任何阻塞代码转换,从两个参数到DTO类的Mono

假设我有如下控制器:

@RestController
@所需参数构造函数
类GithubRepositoryEndpoint{
私人最终GithubService GithubService;
@GetMapping(“/repositories/{owner}/{repositoryName}”)
Mono getRepositoryDetails(@PathVariable(“所有者”)字符串所有者,
@路径变量(“repositoryName”)字符串(repositoryName){
返回githubService.getRepositoryDetails(Mono.just(newrepostailsrequestdto(owner,repositoryName));
}
}
我认为这条线路阻塞了: Mono.just(新的RepoDetailsRequestDTO(所有者、repositoryName)

下面是DTO类:


@资料
@建筑商
@AllArgsConstructor
公共类RepoDetails请求到{
私人字符串所有者;
私有字符串repositoryName;
}
我的服务没有阻塞:

@Slf4j
@所需参数构造函数
公共类服务{
私人最终GithubClient GithubClient;
私有最终请求验证器请求验证器;
私有最终域名映射器域名映射器;
公共Mono getRepositoryDetails(Mono请求){
return request.map(requestValidator::validate)
.map(domainMapper::mapFromDto)
.flatMap(ownerAndReportName->githubClient.fetchRepositoryDetails(ownerAndReportName.\u 1,ownerAndReportName.\u 2))
.onErrorResume(exc->Mono.error(新的FetchRepoDetailsException(exc.getMessage(),exc)));
}
}
线路

Mono.just(new RepoDetailsRequestDTO(owner, repositoryName))

不是阻塞。它只是一个构造函数调用。它不使用任何阻塞API(例如io/文件/网络).owner和repositoryName参数都可以安全访问,因为它们已经包含解析后的路径变量。

是什么让您认为该行正在阻塞?据我所知,阻塞发生的唯一时间是显式调用.block()或.subscribe()