【问题标题】:Error creating bean named `conversionServicePostProcessor` when using spring-boot-admin-server使用 spring-boot-admin-server 时创建名为“conversionServicePostProcessor”的 bean 时出错
【发布时间】:2020-03-14 16:43:05
【问题描述】:

我试图为我的应用程序启用 Spring Boot 管理服务器。默认设置工作得很好,但是当我尝试启用安全性时,我收到以下错误:


应用程序启动失败


说明:

在类路径中定义的 bean 'conversionServicePostProcessor' 资源 [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class], 无法注册。具有该名称的 bean 已经 在类路径资源中定义 [org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.class] 并且覆盖被禁用。

行动:

考虑重命名其中一个 bean 或通过设置启用覆盖 spring.main.allow-bean-definition-overriding=true

进程以退出代码 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)

}

【问题讨论】:

  • 我也有同样的问题。你能找到解决办法吗?

标签: kotlin spring-security spring-boot-admin


【解决方案1】:

我找到了更新文档的拉取请求:https://github.com/spring-projects/spring-boot/issues/14069

对于反应式 WebSocket, {spring-reference}web-reactive.html#webflux-websocket[Spring WebFlux] 提供了丰富的支持, 可通过spring-boot-starter-webflux 模块访问。 请参阅spring-boot-sample-websocket-reactive 示例项目以了解 WebSockets 如何可能 使用 Spring WebFlux 实现。

原来使用webflux和websocket会导致冲突。

也在这个拉取请求中被拒绝解决冲突 https://github.com/spring-projects/spring-boot/issues/14810

对于响应式 websocket,请参阅此示例 https://www.baeldung.com/spring-5-reactive-websockets

【讨论】:

  • 谢谢@Sergey。回答问题永远不会太晚。肯定会对面临这个问题的每个人有用。
【解决方案2】:

我有同样的问题,并能够通过添加解决它

spring.main.allow-bean-definition-overriding=true

到我的 application.properties。

听起来像是一种解决方法,而且仅当我将其部署为 WAR 时才需要它——作为一个独立的应用程序,从未发生过异常。

【讨论】:

  • 不像你,对我来说,包装是Jar时抛出异常。
【解决方案3】:

我也遇到了这个错误,在重新导入所有 Mavne 项目(Intellij IDE)之后它对我来说很好。这是我对这个问题的详细意见here

【讨论】:

    猜你喜欢
    • 2023-02-09
    • 2019-02-12
    • 2020-06-05
    • 1970-01-01
    • 1970-01-01
    • 2022-07-01
    • 2015-02-25
    • 2015-07-28
    • 2018-01-25
    相关资源
    最近更新 更多