Summary

When configuring WebFluxSecurityConfiguration and WebMvcSecurityConfiguration, following problem would occour at runtime: ```` 2018-10-26 16:29:04.215 WARN 34848 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'requestDataValueProcessor' defined in class path resource [org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.security.config.annotation.web.reactive.WebFluxSecurityConfiguration; factoryMethodName=requestDataValueProcessor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.class]] for bean 'requestDataValueProcessor': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.security.config.annotation.web.configuration.WebMvcSecurityConfiguration; factoryMethodName=requestDataValueProcessor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebMvcSecurityConfiguration.class]] bound. 2018-10-26 16:29:04.228 INFO 34848 --- [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2018-10-26 16:29:04.232 ERROR 34848 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

The bean 'requestDataValueProcessor', defined in class path resource [org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebMvcSecurityConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

`````

Actual Behavior

Expected Behavior

Both - WebFluxSecurity and WebMvcSecurity - can be used without interfering.

Configuration

Version

Occurred in 5.1.1.RELEASE Works in 5.0.6.RELEASE

Sample

Comment From: rwinch

You cannot use Spring MVC and WebFlux at the same time so why would you expect to have both of these configurations at the same time?

Comment From: msteigenberger

Ok, understood that using Webflux and WebMVC in parallel in one application is not supported (was not intended to be supported). Hence closing this issue.

Comment From: balasenthil-d

I am facing the same problem. Both Spring MVC and webflux come as part of spring-boot-starter-webflux right. How can I exclude Spring MVC ?

Comment From: jzheaux

@balasenthil-d I'm not sure I understand the problem you are having, no extra work should need to be done to exclude Spring MVC, so I'm imagining that you are perhaps invoking it somehow, for example by using both @EnableWebSecurity and @EnableWebFluxSecurity.

Comment From: satishpatro44

@jzheaux , I an getting this error even if I don't have @EnableWebSecurity, I have only @EnableWebFluxSecurity

Comment From: jzheaux

Hi, @satishpatro44! If you think you've found a bug, please file an issue with a reproducer. If you just have a question, please post to StackOverflow.

Comment From: romainvandecaveye

I dont know if this will be read, but I had the same issue and solved it by removing the following dependency :

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </dependency>