首页 > 其他分享 >webFlux 路由post请求时依赖注入字段报null

webFlux 路由post请求时依赖注入字段报null

时间:2022-10-26 10:33:05浏览次数:90  
标签:loginAuthentication webFlux request authHandler b1 b2 post null id

有下列代码:

@Autowired
AuthHandler authHandler;

RouterFunction<ServerResponse> doctorRouter =
         RouterFunctions.route()
                .path("/doctors", b1 -> b1
                        .nest(accept(MediaType.APPLICATION_JSON), b2 -> b2
                                .GET("/{id}", request -> ServerResponse.ok()
                                     .body(feignService.getDoctorById(request.headers().header("Authorization").get(0), Integer.valueOf(request.pathVariable("id"))),
                                                String.class)
                                )
                              .POST(authHandler::loginAuthentication)

                        ))
                .build();

当起动spring程序时报authHandler为空

但是当把代码修改为如下:

 RouterFunction<ServerResponse> doctorRouter(){
        return RouterFunctions.route()
                .path("/doctors", b1 -> b1
                        .nest(accept(MediaType.APPLICATION_JSON), b2 -> b2
                                .GET("/{id}", request -> ServerResponse.ok()
                                        .body(feignService
                                                .getDoctorById(request.headers().header("Authorization").get(0), Integer.valueOf(request.pathVariable("id"))),
                                                String.class)
                                )
                                .POST(authHandler::loginAuthentication)
                        ))
                .build();

   }

这里spring起动成功,有哪位大神知道原因?敬请留言。



来自为知笔记(Wiz)

标签:loginAuthentication,webFlux,request,authHandler,b1,b2,post,null,id
From: https://www.cnblogs.com/baiyifengyun/p/16827404.html

相关文章

  • 快速启动postgresql
    文档说明:只记录关键地方;试验环境:linuxdebian11postgresqlcontainerversion:"3"services:postgresql-server:image:postgres:15-alpinec......
  • mybatis typehandler适配postgresql中的point数组数据类型
    mybatistypehandler适配postgresql中的point数组数据类型importlombok.extern.slf4j.Slf4j;importorg.apache.ibatis.type.BaseTypeHandler;importorg.apache.ibat......
  • PostgreSQL 数组类型使用详解
    PostgreSQL数组类型使用详解PostgreSQL数组类型使用详解可能大家对PostgreSQL这个关系型数据库不太熟悉,因为大部分人最熟悉的,公司用的最多的是MySQL我们先对Postgr......
  • PostProcess
    后处理器:AutowiredAnnotationBeanPostProcess.class可以处理@Autowired、@Value如何注册:context.registerBean(xxx.class);CommonAnnotationBeanPostProcess.c......
  • post row 请求数据
    控制器protected$accessTokenUrl="http://www.xxxxx.com:8888/dw/dahua/accesstoken.php";publicfunctiongetaccessToken(){$AppKey=Config::g......
  • Postman汉化教程
    步骤:1:下载中文包2:下载,安装指定版本Postman3:汉化包的解压配置调试一:下载中文包1:下载对应版本的app.zip(注释:可以下载app.zip的最新版本网址:h......
  • CentOS 7.2 源码安装 PostgreSQL 9.0
    安装PGSQLPGSQL源码地址:https://ftp.postgresql.org/pub/source/下载9.0版本源码[root@localhostsoft]#wgethttps://ftp.postgresql.org/pub/source/v9.0.0/postgres......
  • fastposter v2.9.3 简单易用的海报生成器
    ......
  • vscode 设置vue的用户片段-- vue文件 httpget httppost 请求 模板
      文件->首选项->用户片段{"生成vue模板":{"prefix":"vue","body":["<!--$1-->","<template>","<div......
  • 在非controller层中依赖注入为null问题
    我们在项目中,一般在controller层中注入service接口,在service层中注入其它的service接口或者mapper接口都是可以的,但是如果我们要在我们自己封装的Utils工具类中或者非contr......