Error creating bean named `conversionServicePostProcessor` when using spring-boot-admin-server
我正在尝试为我的应用程序启用Spring Boot管理服务器。默认设置可以正常工作,但是当我尝试启用安全性时,出现以下错误:
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=trueProcess finished with exit code 1
我正在使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | @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 thespring-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
我遇到了同样的问题,可以通过添加
来解决
1 | spring.main.allow-bean-definition-overriding=true |
到我的application.properties。
听起来像是一种解决方法,而且只有当我将其部署为WAR时才有必要-作为独立应用程序,永远不会发生异常。