https://kotlinlang.org logo
#spring
Title
# spring
d

dany giguere

03/27/2024, 10:30 PM
I’m trying to create a bff with spring, kotlin (reactive) and graphql. As soon as I added the SecurityConfig class to my bff project, I got this error:
Copy code
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
I don’t understand how I have both …web/configuration/WebSecurityConfiguration.class and …web/reactive/WebFluxSecurityConfiguration.class. I also tried to set the allow-bean-definition-overriding to true but somehow I always get a 401 when trying to reach my api. I guess I need both beans. You can view my SecurityConfig on this repo: https://github.com/danygiguere/graphql-microservice/blob/JWT/bff/src/main/kotlin/com/example/bff/configuration/SecurityConfig.kt. The strange thing is that I implemented the same SecurityConfig in the same repo under the users-service and it works fine. Anyone would happen to know what is going on ?
s

Szymon Jeziorski

03/28/2024, 7:01 AM
com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter
looks to be configured strictly for spring mvc. It brings
spring-boot-starter-web
with itself which causes the clash with your webflux setup. Replace it with webflux variant:
com.netflix.graphql.dgs:graphql-dgs-webflux-starter
and you should be good to go
👍 2
d

dany giguere

03/28/2024, 11:00 AM
A big big THANK YOU @Szymon Jeziorski. I just couldn’t figure it out and was about to give up on graphql. Thank you 🙂
❤️ 1
7 Views