How to get rid of the conversionServicePostProcessor bean conflict?
12:07 20 Oct 2020

I've got a project with the following dependencies:


    
        
            org.springframework.cloud
            spring-cloud-dependencies
            ${spring-cloud.version}
            pom
            import
        
    



    
        org.springframework.boot
        spring-boot-starter-web
    
    
        org.springframework.boot
        spring-boot-starter-logging
    
    
        org.springframework.cloud
        spring-cloud-starter-openfeign
    
    
        org.springframework.boot
        spring-boot-starter-hateoas
    
    
        org.springframework.cloud
        spring-cloud-starter-netflix-ribbon
    
    
        org.springframework.cloud
        spring-cloud-starter-config
    

    
    
        io.projectreactor.kafka
        reactor-kafka
        1.1.0.RELEASE
    
    
        org.apache.kafka
        kafka-clients
        2.0.0
        compile
    
    
        org.springframework.kafka
        spring-kafka
    

    
    
        org.springframework.boot
        spring-boot-starter-data-jpa
        
            
                
                com.zaxxer
                HikariCP
            
        
    
    
        org.flywaydb.enterprise
        flyway-core
        6.2.4
    
    
        org.apache.tomcat
        tomcat-jdbc
    
    
        com.h2database
        h2
        runtime
    
    
        oracle
        oracle-jdbc
        11.2g
    


    
    
        org.springdoc
        springdoc-openapi-common
        ${spring-doc.version}
    
    
        org.springdoc
        springdoc-openapi-webmvc-core
        ${spring-doc.version}
    
    
        org.springdoc
        springdoc-openapi-security
        ${spring-doc.version}
    

    
        commons-io
        commons-io
        2.5
    
    
        commons-codec
        commons-codec
    
    
        com.ibm.icu
        icu4j
        62.1
    
    
        org.apache.httpcomponents
        httpclient
    

    
        org.springframework.boot
        spring-boot-starter-actuator
    

    
        org.projectlombok
        lombok
        true
    
    
        org.springframework.boot
        spring-boot-configuration-processor
        true
    
    
        org.springframework.boot
        spring-boot-devtools
    

    
        org.springframework.boot
        spring-boot-starter-test
        test
    
    
        org.springframework.cloud
        spring-cloud-stream-test-support
        test
    

    
    
        org.springframework.boot
        spring-boot-starter-security
    

    
    
        org.springframework.security
        spring-security-oauth2-jose
    
    
        org.springframework.security
        spring-security-oauth2-resource-server
    

    
        org.springframework.security
        spring-security-test
        test
    


    
        org.springframework.boot
        spring-boot-starter-webflux
    
    
        io.projectreactor
        reactor-core
        ${reactor.version}
    
    
        io.projectreactor.addons
        reactor-extra
        ${reactor.version}
    

    
        io.projectreactor
        reactor-test
        test
    

    
        javax.interceptor
        javax.interceptor-api
        1.2
    

    
        com.fasterxml.jackson.dataformat
        jackson-dataformat-yaml
        ${jackson.version}
    

    
        com.squareup.okhttp3
        mockwebserver
        ${okhttp3.version}
        test
    

    
        org.apache.commons
        commons-lang3
        3.9
    
    
        org.jetbrains.kotlin
        kotlin-stdlib
        ${kotlin.version}
    
    
        org.jetbrains.kotlin
        kotlin-reflect
        ${kotlin.version}
    
    
        org.jetbrains.kotlin
        kotlin-test-junit
        ${kotlin.version}
        test
    



    
        
            
                org.apache.maven.plugins
                maven-release-plugin
                2.5.3
            
        
    

    
        
            ${project.basedir}/target/ansible_sources
            true
            
                **/vars.yml
            
        
        
            ${project.basedir}/src/main/resources
            true
            
                **/*.jks
            
        
        
            ${project.basedir}/src/main/resources
            false
            
                **/*.jks
            
        
    

    
        
            org.springframework.boot
            spring-boot-maven-plugin
            
                
                    
                        build-info
                    
                
            
        
        
            pl.project13.maven
            git-commit-id-plugin
            2.2.6
        
        
            org.jacoco
            jacoco-maven-plugin
            0.8.1
            
                
                    default-prepare-agent
                    
                        prepare-agent
                    
                
                
                    default-report
                    prepare-package
                    
                        report
                    
                
            
        
        
            org.jetbrains.kotlin
            kotlin-maven-plugin
            ${kotlin.version}
            
                
                    compile
                    compile
                    
                        compile
                    
                
                
                    test-compile
                    test-compile
                    
                        test-compile
                    
                
            
        
        
            org.apache.maven.plugins
            maven-compiler-plugin
            
                
                    compile
                    compile
                    
                        compile
                    
                
                
                    testCompile
                    test-compile
                    
                       testCompile
                    
                
            
        
    

dependency tree (incomplete, skipping several common dependencies to be within character limit):

 --- maven-dependency-plugin:3.1.1:tree (default-cli) @ projectName ---

 projectName:jar:0.0.12-SNAPSHOT


 +- org.springframework.cloud:spring-cloud-starter-openfeign:jar:2.2.4.RELEASE:compile

 |  +- org.springframework.cloud:spring-cloud-starter:jar:2.2.4.RELEASE:compile

 |  |  +- org.springframework.cloud:spring-cloud-context:jar:2.2.4.RELEASE:compile

 |  |  \- org.springframework.security:spring-security-rsa:jar:1.0.9.RELEASE:compile

 |  |     \- org.bouncycastle:bcpkix-jdk15on:jar:1.64:compile

 |  +- org.springframework.cloud:spring-cloud-openfeign-core:jar:2.2.4.RELEASE:compile

 |  |  \- io.github.openfeign.form:feign-form-spring:jar:3.8.0:compile

 |  |     +- io.github.openfeign.form:feign-form:jar:3.8.0:compile

 |  |     \- commons-fileupload:commons-fileupload:jar:1.4:compile

 |  +- org.springframework:spring-web:jar:5.2.3.RELEASE:compile

 |  |  \- org.springframework:spring-beans:jar:5.2.3.RELEASE:compile

 |  +- org.springframework.cloud:spring-cloud-commons:jar:2.2.4.RELEASE:compile

 |  |  \- org.springframework.security:spring-security-crypto:jar:5.2.1.RELEASE:compile

 |  +- io.github.openfeign:feign-core:jar:10.10.1:compile

 |  +- io.github.openfeign:feign-slf4j:jar:10.10.1:compile

 |  \- io.github.openfeign:feign-hystrix:jar:10.10.1:compile

 |     +- com.netflix.archaius:archaius-core:jar:0.7.6:compile

 |     \- com.netflix.hystrix:hystrix-core:jar:1.5.18:compile

 |        \- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile

 +- org.springframework.boot:spring-boot-starter-hateoas:jar:2.2.3.RELEASE:compile

 |  +- org.springframework.boot:spring-boot-starter-web:jar:2.2.3.RELEASE:compile

 |  |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.2.3.RELEASE:compile

 |  |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.30:compile

 |  |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.30:compile

 |  |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.30:compile

 |  |  \- org.springframework:spring-webmvc:jar:5.2.3.RELEASE:compile

 |  \- org.springframework.hateoas:spring-hateoas:jar:1.0.3.RELEASE:compile

 |     \- org.springframework.plugin:spring-plugin-core:jar:2.0.0.RELEASE:compile

 +- org.springframework.cloud:spring-cloud-starter-netflix-ribbon:jar:2.2.4.RELEASE:compile

 |  +- org.springframework.cloud:spring-cloud-netflix-ribbon:jar:2.2.4.RELEASE:compile

 |  |  \- org.springframework.cloud:spring-cloud-netflix-archaius:jar:2.2.4.RELEASE:compile

 |  +- org.springframework.cloud:spring-cloud-starter-netflix-archaius:jar:2.2.4.RELEASE:compile

 |  |  \- commons-configuration:commons-configuration:jar:1.8:compile


 |  +- com.netflix.ribbon:ribbon-core:jar:2.3.0:compile

 |  |  \- commons-lang:commons-lang:jar:2.6:compile

 |  +- com.netflix.ribbon:ribbon-httpclient:jar:2.3.0:compile

 |  |  +- commons-collections:commons-collections:jar:3.2.2:runtime

 |  |  +- com.sun.jersey:jersey-client:jar:1.19.1:compile

 |  |  |  \- com.sun.jersey:jersey-core:jar:1.19.1:compile

 |  |  |     \- javax.ws.rs:jsr311-api:jar:1.1.1:compile

 |  |  +- com.sun.jersey.contribs:jersey-apache-client4:jar:1.19.1:compile

 |  |  +- com.netflix.servo:servo-core:jar:0.12.21:runtime

 |  |  \- com.netflix.netflix-commons:netflix-commons-util:jar:0.3.0:runtime

 |  +- com.netflix.ribbon:ribbon-loadbalancer:jar:2.3.0:compile

 |  |  \- com.netflix.netflix-commons:netflix-statistics:jar:0.1.1:runtime

 |  \- io.reactivex:rxjava:jar:1.3.8:compile

 +- org.springframework.cloud:spring-cloud-starter-config:jar:2.2.4.RELEASE:compile

 |  +- org.springframework.cloud:spring-cloud-config-client:jar:2.2.4.RELEASE:compile

 |  |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.0:compile

 |  \- com.fasterxml.jackson.core:jackson-databind:jar:2.11.0:compile

 +- io.projectreactor.kafka:reactor-kafka:jar:1.1.0.RELEASE:compile

 +- org.flywaydb.enterprise:flyway-core:jar:6.2.4:compile

 +- org.apache.tomcat:tomcat-jdbc:jar:9.0.30:compile

 |  \- org.apache.tomcat:tomcat-juli:jar:9.0.30:compile

 +- com.h2database:h2:jar:1.4.200:runtime

 +- oracle:oracle-jdbc:jar:11.2g:compile

 +- commons-io:commons-io:jar:2.5:compile

 +- commons-codec:commons-codec:jar:1.13:compile

 +- com.ibm.icu:icu4j:jar:62.1:compile

 +- org.apache.httpcomponents:httpclient:jar:4.5.10:compile

 |  \- org.apache.httpcomponents:httpcore:jar:4.4.13:compile

 +- org.springframework.boot:spring-boot-configuration-processor:jar:2.2.3.RELEASE:compile (optional)

 +- org.springframework.boot:spring-boot-devtools:jar:2.2.3.RELEASE:compile

 |  +- org.springframework.boot:spring-boot:jar:2.2.3.RELEASE:compile

 |  \- org.springframework.boot:spring-boot-autoconfigure:jar:2.2.3.RELEASE:compile
    
 +- org.springframework.cloud:spring-cloud-stream-test-support:jar:3.0.7.RELEASE:test

 |  \- org.springframework.cloud:spring-cloud-stream:jar:3.0.7.RELEASE:test

 |     +- org.springframework.integration:spring-integration-core:jar:5.2.3.RELEASE:test

 |     +- org.springframework.integration:spring-integration-jmx:jar:5.2.3.RELEASE:test

 |     \- org.springframework.cloud:spring-cloud-function-context:jar:3.0.9.RELEASE:test

 |        +- net.jodah:typetools:jar:0.6.2:test

 |        \- org.springframework.cloud:spring-cloud-function-core:jar:3.0.9.RELEASE:test

 +- org.springframework.boot:spring-boot-starter-security:jar:2.2.3.RELEASE:compile

 |  +- org.springframework:spring-aop:jar:5.2.3.RELEASE:compile

 |  +- org.springframework.security:spring-security-config:jar:5.2.1.RELEASE:compile

 |  \- org.springframework.security:spring-security-web:jar:5.2.1.RELEASE:compile

 +- org.springframework.security:spring-security-oauth2-jose:jar:5.2.1.RELEASE:compile

 |  +- com.nimbusds:nimbus-jose-jwt:jar:7.8:compile

 |  |  \- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile

 |  +- org.springframework.security:spring-security-core:jar:5.2.1.RELEASE:compile

 |  \- org.springframework.security:spring-security-oauth2-core:jar:5.2.1.RELEASE:compile

 +- org.springframework.security:spring-security-oauth2-resource-server:jar:5.2.1.RELEASE:compile

 +- org.springframework.security:spring-security-test:jar:5.2.1.RELEASE:test

 +- org.springframework.boot:spring-boot-starter-webflux:jar:2.2.3.RELEASE:compile

 |  +- org.springframework.boot:spring-boot-starter-json:jar:2.2.3.RELEASE:compile

 |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.0:compile

 |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.0:compile

 |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.0:compile

 |  +- org.springframework.boot:spring-boot-starter-reactor-netty:jar:2.2.3.RELEASE:compile

 |  |  +- io.projectreactor.netty:reactor-netty:jar:0.9.3.RELEASE:compile

 |  |  |  +- io.netty:netty-codec-http:jar:4.1.45.Final:compile

 |  |  |  |  +- io.netty:netty-common:jar:4.1.45.Final:compile

 |  |  |  |  +- io.netty:netty-buffer:jar:4.1.45.Final:compile

 |  |  |  |  +- io.netty:netty-transport:jar:4.1.45.Final:compile

 |  |  |  |  |  \- io.netty:netty-resolver:jar:4.1.45.Final:compile

 |  |  |  |  \- io.netty:netty-codec:jar:4.1.45.Final:compile

 |  |  |  +- io.netty:netty-codec-http2:jar:4.1.45.Final:compile

 |  |  |  +- io.netty:netty-handler:jar:4.1.45.Final:compile

 |  |  |  +- io.netty:netty-handler-proxy:jar:4.1.45.Final:compile

 |  |  |  |  \- io.netty:netty-codec-socks:jar:4.1.45.Final:compile

 |  |  |  \- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.45.Final:compile

 |  |  |     \- io.netty:netty-transport-native-unix-common:jar:4.1.45.Final:compile

 |  |  \- org.glassfish:jakarta.el:jar:3.0.3:compile

 |  +- org.springframework.boot:spring-boot-starter-validation:jar:2.2.3.RELEASE:compile

 |  |  +- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile

 |  |  \- org.hibernate.validator:hibernate-validator:jar:6.0.18.Final:compile

 |  +- org.springframework:spring-webflux:jar:5.2.3.RELEASE:compile

 |  \- org.synchronoss.cloud:nio-multipart-parser:jar:1.1.0:compile

 |     \- org.synchronoss.cloud:nio-stream-storage:jar:1.1.3:compile

 +- io.projectreactor:reactor-core:jar:3.3.0.RELEASE:compile

 |  \- org.reactivestreams:reactive-streams:jar:1.0.3:compile

 +- io.projectreactor.addons:reactor-extra:jar:3.3.0.RELEASE:compile

 +- io.projectreactor:reactor-test:jar:3.3.2.RELEASE:test

 +- javax.interceptor:javax.interceptor-api:jar:1.2:compile

 +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.11.0:compile

 |  +- org.yaml:snakeyaml:jar:1.25:compile

 |  \- com.fasterxml.jackson.core:jackson-core:jar:2.11.0:compile

 +- com.squareup.okhttp3:mockwebserver:jar:3.8.1:test

 |  +- com.squareup.okhttp3:okhttp:jar:3.8.1:test

 |  |  \- com.squareup.okio:okio:jar:1.13.0:test

 |  +- org.bouncycastle:bcprov-jdk15on:jar:1.50:compile

 |  \- junit:junit:jar:4.12:test

 |     \- org.hamcrest:hamcrest-core:jar:2.1:test

 +- org.apache.commons:commons-lang3:jar:3.9:compile

 +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.3.61:compile

 |  +- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.3.61:compile

 |  \- org.jetbrains:annotations:jar:13.0:compile

 +- org.jetbrains.kotlin:kotlin-reflect:jar:1.3.61:compile

 \- org.jetbrains.kotlin:kotlin-test-junit:jar:1.3.61:test

    +- org.jetbrains.kotlin:kotlin-test-annotations-common:jar:1.3.61:test

    \- org.jetbrains.kotlin:kotlin-test:jar:1.3.61:test

       \- org.jetbrains.kotlin:kotlin-test-common:jar:1.3.61:test

It is a microservice using other microservices and exposing a reactive rest API. After I've added the security dependencies Tests do not run anymore, building context fails with the following error:

Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException:

Invalid bean definition with name 'conversionServicePostProcessor'

defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]:

Cannot register bean definition [Root bean: class [org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=conversionServicePostProcessor; initMethodName=null; destroyMethodName=(inferred);

defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]] for bean 'conversionServicePostProcessor':

There is already [Root bean: class [org.springframework.security.config.annotation.web.reactive.WebFluxSecurityConfiguration]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=conversionServicePostProcessor; initMethodName=null; destroyMethodName=(inferred);

defined in class path resource [org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.class]] bound.

How can I get rid of the error and use my reactive spring security?

I've tried to filter the WebSecurityConfiguration with the Component scan, setting the application type as reactive and removing all the dependencies I could - did not help.

spring spring-boot spring-security spring-reactive