【问题标题】:EnableWebFluxSecurity contadiction with web dependencyEnableWebFluxSecurity 与 Web 依赖的冲突
【发布时间】:2019-06-28 16:26:24
【问题描述】:

我正在尝试用 @EnableWebFluxSecurity 注释 SecurityWebFilterChain 类:

@EnableWebFluxSecurity
public class AccessIqWebSecurityConfigurerAdapter {

我在启动应用程序时收到以下错误:

org.springframework.beans.factory.UnsatisfiedDependencyException: 创建具有名称的 bean 时出错 'org.springframework.security.config.annotation.web.reactive.WebFluxSecurityConfiguration': 通过字段表示的不满足的依赖关系 'securityWebFilterChains';嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建类中定义的名称为“springSecurityFilterChain”的bean 路径资源 [com/config/AccessIqWebSecurityConfigurerAdapter.class]: 通过工厂方法实例化 Bean 失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:失败 实例化 [org.springframework.security.web.server.SecurityWebFilterChain]: 工厂方法“springSecurityFilterChain”抛出异常;嵌套的 例外是 java.lang.IllegalArgumentException: clientRegistrationRepository 不能为空

当我删除compile("org.springframework.boot:spring-boot-starter-web")。有用。但我需要compile("org.springframework.boot:spring-boot-starter-web") 来表达招摇、Mockmvc 等任何想法?

【问题讨论】:

    标签: spring-security spring-webflux


    【解决方案1】:

    As stated in the reference documentation,将 spring-boot-starter-web 依赖添加到您的应用程序将告诉 Spring Boot 将其配置为 Spring MVC 应用程序。

    您可以向 Spring Boot 提供另一个提示,使其仍然是 Spring WebFlux 应用程序(通过 SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE)),但这对您的情况没有帮助:

    • 您必须使用与 WebFlux 兼容的 swagger 集成(我不知道是否存在)
    • 你应该考虑 WebTestClient 而不是 MockMvc

    【讨论】:

      猜你喜欢
      • 2018-10-24
      • 2016-11-05
      • 2017-10-15
      • 2019-08-08
      • 2020-06-24
      • 2021-11-05
      • 2018-11-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多