title: Error when using @EnableWebFluxSecurity in springboot
body: <p>Currently I´m trying to integrate JWT Authentication in an existing Spring Boot Webflux Project.
  As a template I used this medium article: <a href="https://medium.com/@ard333/authentication-and-authorization-using-jwt-on-spring-webflux-29b81f813e78" rel="noreferrer">https://medium.com/@ard333/authentication-and-authorization-using-jwt-on-spring-webflux-29b81f813e78</a>.<br />
  If I put the Annotation @EnableWebFluxSecurity inside my WebSecurityConfig the following error occurs:</p>
  <blockquote>
  <p>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.</p>
  </blockquote>
  <p>Basicaly it´s the same error as in this post <a href="https://stackoverflow.com/questions/58929368/error-creating-bean-named-conversionservicepostprocessor-when-using-spring-boo">Error creating bean named `conversionServicePostProcessor` when using spring-boot-admin-server</a> but the answers didn´t help for me and I can´t comment on answers.</p>
  <p>In the previous post two solutions are mentioned that didn´t work for me.
  Removing the websocket dependency didn´t help and setting &quot;spring.main.allow-bean-definition-overriding=true&quot; seems to override my own Configuration, because my route /auth/login/guest is still responding 401.</p>
  <p>Here is my WebSecurityConfiguration:</p>
  <pre class="lang-java prettyprint-override"><code>package de.thm.arsnova.frag.jetzt.backend.config;
  
  import de.thm.arsnova.frag.jetzt.backend.security.AuthenticationManager;
  import de.thm.arsnova.frag.jetzt.backend.security.SecurityContextRepository;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.http.HttpMethod;
  import org.springframework.http.HttpStatus;
  import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity;
  import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
  import org.springframework.security.config.web.server.ServerHttpSecurity;
  import org.springframework.security.web.server.SecurityWebFilterChain;
  import reactor.core.publisher.Mono;
  
  @Configuration
  @EnableWebFluxSecurity
  @EnableReactiveMethodSecurity
  public class WebSecurityConfig {
  
      private final AuthenticationManager authenticationManager;
      private final SecurityContextRepository securityContextRepository;
  
      @Autowired
      public WebSecurityConfig(AuthenticationManager authenticationManager, SecurityContextRepository securityContextRepository) {
          this.authenticationManager = authenticationManager;
          this.securityContextRepository = securityContextRepository;
      }
  
      @Bean
      public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
          return http
                  .exceptionHandling()
                  .authenticationEntryPoint((swe, e) -&gt;
                          Mono.fromRunnable(() -&gt; swe.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED))
                  ).accessDeniedHandler((swe, e) -&gt;
                          Mono.fromRunnable(() -&gt; swe.getResponse().setStatusCode(HttpStatus.FORBIDDEN))
                  ).and()
                  .csrf().disable()
                  .formLogin().disable()
                  .httpBasic().disable()
                  .authenticationManager(authenticationManager)
                  .securityContextRepository(securityContextRepository)
                  .authorizeExchange()
                  .pathMatchers(HttpMethod.OPTIONS).permitAll()
                  .pathMatchers(&quot;/auth/login/guest&quot;).permitAll()
                  .anyExchange().authenticated()
                  .and().build();
      }
  }
  </code></pre>
  <p>and my pom.xml</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;de.thm.arsnova.frag.jetzt&lt;/groupId&gt;
      &lt;artifactId&gt;frag.jetzt-backend&lt;/artifactId&gt;
      &lt;version&gt;0.1.0&lt;/version&gt;
  
      &lt;properties&gt;
          &lt;spring-boot-version&gt;2.3.0.RELEASE&lt;/spring-boot-version&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
  
      &lt;dependencyManagement&gt;
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-dependencies&lt;/artifactId&gt;
                  &lt;version&gt;${spring-boot-version}&lt;/version&gt;
                  &lt;type&gt;pom&lt;/type&gt;
                  &lt;scope&gt;import&lt;/scope&gt;
              &lt;/dependency&gt;
          &lt;/dependencies&gt;
      &lt;/dependencyManagement&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-amqp&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-websocket&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-webflux&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-r2dbc&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.r2dbc&lt;/groupId&gt;
              &lt;artifactId&gt;r2dbc-postgresql&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
              &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.flywaydb&lt;/groupId&gt;
              &lt;artifactId&gt;flyway-core&lt;/artifactId&gt;
              &lt;version&gt;6.0.8&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt;
              &lt;artifactId&gt;jjwt-api&lt;/artifactId&gt;
              &lt;version&gt;0.11.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt;
              &lt;artifactId&gt;jjwt-impl&lt;/artifactId&gt;
              &lt;version&gt;0.11.1&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt;
              &lt;artifactId&gt;jjwt-jackson&lt;/artifactId&gt;
              &lt;version&gt;0.11.1&lt;/version&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;!-- LogBack dependencies --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
              &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;jcl-over-slf4j&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.8.0&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.8&lt;/source&gt;
                      &lt;target&gt;1.8&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
                  &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;0.8.5&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;default-prepare-agent&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;prepare-agent&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                      &lt;execution&gt;
                          &lt;id&gt;default-report&lt;/id&gt;
                          &lt;phase&gt;prepare-package&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;report&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;repackage&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;version&gt;${spring-boot-version}&lt;/version&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.flywaydb&lt;/groupId&gt;
                  &lt;artifactId&gt;flyway-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;6.4.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;url&gt;jdbc:postgresql://localhost:5432/fragjetzt&lt;/url&gt;
                      &lt;user&gt;fragjetzt&lt;/user&gt;
                      &lt;password&gt;fragjetzt&lt;/password&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  
  </code></pre>