Error creating bean named `conversionServicePostProcessor` when using spring-boot-admin-server
Asked Answered
B

4

15

I was trying to enable Spring boot admin server for my application. The default settings work perfectly fine but when I attempt to enable security, I am getting following error:


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

I am using the latest SNAPSHOT version of spring-boot-admin-starter-server (2.2.0-SNAPSHOT). Here is my security configuration:

@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)

}
Barde answered 19/11, 2019 at 8:14 Comment(1)
I have the same issue. Could you find a way to fix it?Revere
B
8

I found a pull request to update the documentation: 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.

it turns out that using webflux and websocket leads to conflicts.

also in this pull request was denied in the resolution of the conflict https://github.com/spring-projects/spring-boot/issues/14810

for reactive websocket see this sample https://www.baeldung.com/spring-5-reactive-websockets

Bollworm answered 25/1, 2020 at 18:5 Comment(1)
Thanks @Sergey. It's never too late to answer a question. Will certainly be useful to everyone facing this issue.Barde
P
4

I had the same issue and was able solve it by adding

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

to my application.properties.

Sounds like a workaround and it was also only necessary if I deployed it as WAR -- as a standalone application the exception never occured.

Punke answered 31/5, 2020 at 8:56 Comment(2)
Unlike you, for me, the exception was thrown when packaging was Jar.Barde
This is working for me as well but not making me happy though.Platy
C
4

As above it is the conflict between web flux and reactive. Update your application properties to include the following to neatly solve this issue:

spring.main.web-application-type=reactive

I don't believe allow bean overrides would be a great solution.

Cuesta answered 10/2 at 9:14 Comment(0)
C
-1

I also faced this error, after Reimport All Mavne Projects(Intellij IDE) it works fine for me. Here my detailed input on this issue here

Chanell answered 28/1, 2022 at 14:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.