使用 spring-boot-admin-server 创建名为“conversionServicePostProcessor”的 bean 时出错
Error creating bean named `conversionServicePostProcessor` when using spring-boot-admin-server
我试图为我的应用程序启用 Spring 引导管理服务器。默认设置工作得很好,但是当我尝试启用安全性时,出现以下错误:
APPLICATION FAILED TO START
Description:
The bean 'conversionServicePostProcessor', defined in class path
resource
[org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.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.
Action:
Consider renaming one of the beans or enabling overriding by setting
spring.main.allow-bean-definition-overriding=true
Process finished with exit code 1
我正在使用 spring-boot-admin-starter-server
的最新 SNAPSHOT 版本 (2.2.0-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)
}
我找到了更新文档的拉取请求:https://github.com/spring-projects/spring-boot/issues/14069
For Reactive WebSockets,
{spring-reference}web-reactive.html#webflux-websocket[Spring WebFlux] offers rich support,
which is accessible through the spring-boot-starter-webflux
module.
See the spring-boot-sample-websocket-reactive
sample project to see how WebSockets may
be implemented using Spring WebFlux.
原来使用webflux和websocket会导致冲突
同样在这个拉取请求中被拒绝解决冲突
https://github.com/spring-projects/spring-boot/issues/14810
对于反应式 websocket,请参阅此示例 https://www.baeldung.com/spring-5-reactive-websockets
我遇到了同样的问题,可以通过添加
来解决
spring.main.allow-bean-definition-overriding=true
给我的 application.properties.
听起来像是一种解决方法,而且只有当我将其部署为 WAR 时才需要它——作为一个独立的应用程序,从未发生过异常。
我也遇到了这个错误,在重新导入所有 Maven 项目(Intellij IDE)后它对我来说工作正常。这是我对这个问题的详细输入 here
我试图为我的应用程序启用 Spring 引导管理服务器。默认设置工作得很好,但是当我尝试启用安全性时,出现以下错误:
APPLICATION FAILED TO START
Description:
The bean 'conversionServicePostProcessor', defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.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.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Process finished with exit code 1
我正在使用 spring-boot-admin-starter-server
的最新 SNAPSHOT 版本 (2.2.0-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)
}
我找到了更新文档的拉取请求:https://github.com/spring-projects/spring-boot/issues/14069
For Reactive WebSockets, {spring-reference}web-reactive.html#webflux-websocket[Spring WebFlux] offers rich support, which is accessible through the
spring-boot-starter-webflux
module. See thespring-boot-sample-websocket-reactive
sample project to see how WebSockets may be implemented using Spring WebFlux.
原来使用webflux和websocket会导致冲突
同样在这个拉取请求中被拒绝解决冲突 https://github.com/spring-projects/spring-boot/issues/14810
对于反应式 websocket,请参阅此示例 https://www.baeldung.com/spring-5-reactive-websockets
我遇到了同样的问题,可以通过添加
来解决spring.main.allow-bean-definition-overriding=true
给我的 application.properties.
听起来像是一种解决方法,而且只有当我将其部署为 WAR 时才需要它——作为一个独立的应用程序,从未发生过异常。
我也遇到了这个错误,在重新导入所有 Maven 项目(Intellij IDE)后它对我来说工作正常。这是我对这个问题的详细输入 here