环境:Spring Boot 2.3.1、Java 11
我已经尝试了一些东西(也与 spring 的示例应用程序进行比较),但到目前为止,我未能成功创建WebClient
需要ReactiveClientRegistrationRepository
.
启动我的 spring-boot 应用程序时出现以下异常:
required a bean of type 'org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository'
Run Code Online (Sandbox Code Playgroud)
我理解 spring-boot-autoconfigure 的方式应该使用ReactiveOAuth2ClientAutoConfiguration
,因为在 yml 文件中给出了所需的属性。
根据一些代码片段,如果缺少某些内容,我可以提供更多信息以获取整个上下文
主级
@Slf4j
@SpringBootApplication
@EnableConfigurationProperties(MyAppConfigurationProperties.class)
public class MyApp{
public static void main(final String[] args) {
SpringApplication.run(MyApp.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
配置:
@Configuration
//@Import(ReactiveOAuth2ClientAutoConfiguration.class) // in the test it works with this, but should not be required: spring-boot-autoconfigure
public class MyRestClientConfig {
@Bean
WebClient myWebClient(WebClient.Builder builder, ReactiveClientRegistrationRepository clientRegistrations) {
//content not relevant to this …
Run Code Online (Sandbox Code Playgroud) 我试图为我的应用程序启用 Spring Boot 管理服务器。默认设置工作得很好,但是当我尝试启用安全性时,出现以下错误:
应用程序无法启动
描述:
无法注册在类路径资源 [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class] 中定义的 bean 'conversionServicePostProcessor'。具有该名称的 bean 已经在类路径资源 [org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.class] 中定义并且覆盖被禁用。
行动:
考虑通过设置 spring.main.allow-bean-definition-overriding=true 重命名其中一个 bean 或启用覆盖
进程以退出代码 1 结束
我正在使用spring-boot-admin-starter-server
(2.2.0-SNAPSHOT)的最新 SNAPSHOT 版本。这是我的安全配置:
@EnableAdminServer
@EnableWebFluxSecurity
@Configuration(proxyBeanMethods = false)
class AdminServerSecurityConfigurations(val adminServerProperties: AdminServerProperties) {
@Bean
fun adminServerSecurityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain = http
// @formatter:off
.authorizeExchange()
.pathMatchers("${adminServerProperties.contextPath}/assets/**").permitAll()
.pathMatchers("${adminServerProperties.contextPath}/login").permitAll()
.anyExchange().authenticated().and()
.formLogin().loginPage("${adminServerProperties.contextPath}/login").and()
.logout().logoutUrl("${adminServerProperties.contextPath}/logout").and()
.httpBasic().and()
// @formatter:on
.csrf().disable()
.build()
@Bean
fun notifyLogger(instanceRepository: InstanceRepository) = LoggingNotifier(instanceRepository)
}
Run Code Online (Sandbox Code Playgroud) 我尝试在我的项目中使用SpringWebFluxSecurity
,但编译时出现此错误
The bean 'requestDataValueProcessor', defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebMvcSecurityConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.class] and overriding is disabled.
我知道我必须删除对WebMvcSecurityConfiguration
. 问题是我无法弄清楚在我的项目中调用该配置的位置。您知道如何找到它吗?