我正在禁用测试配置文件的Spring Security ,如下所示:
spring:
config:
activate:
on-profile: test
autoconfigure:
exclude[0]: org.springframework.boot.actuate.autoconfigure.security.reactive.ReactiveManagementWebSecurityAutoConfiguration
exclude[1]: org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration
错误:
Failed to load ApplicationContext
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/reactive/ReactiveOAuth2ClientConfigurations$ReactiveOAuth2ClientConfiguration$SecurityWebFilterChainConfiguration.class]: Unsatisfied dependency expressed through method 'springSecurityFilterChain' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.config.web.server.ServerHttpSecurity' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
1条答案
按热度按时间axkjgtzd1#
有一点需要澄清的是,您没有禁用SpringSecurity,而是禁用了SpringSecurity的SpringBoot自动配置。您可以在spring引导参考文档中阅读更多关于这方面的内容。
在您的配置中,您正在禁用
ReactiveSecurityAutoConfiguration
,但ReactiveOAuth2ClientAutoConfiguration
仍然启用,可能是因为您有一个依赖项,例如spring-boot-starter-oauth2-client
.如错误消息中所述
ReactiveOAuth2ClientAutoConfiguration
正在尝试创建一个SecurityWebFilterChain
bean,但无法注入所需的ServerHttpSecurity
豆子,因为ReactiveSecurityAutoConfiguration
它是残疾的。要修复错误消息,还可以禁用oauth 2.0客户端自动配置。