具有网络依赖性的EnableWebFluxSecurity污染

时间:2019-02-04 21:20:42

标签: spring-security spring-webflux

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

@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等。有什么主意吗?

1 个答案:

答案 0 :(得分:0)

As stated in the reference documentation,向您的应用程序添加onAttach()依赖项将告诉Spring Boot将其配置为Spring MVC应用程序。

您可以给Spring Boot另一个提示,使其仍然是Spring WebFlux应用程序(通过spring-boot-starter-web),但这对您没有帮助:

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