Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

springfox-swagger2:3.0.0-SNAPSHOT Generates conflict of the beans 'requestMappingHandlerAdapter #3342

Closed
josuemojena opened this issue Jun 25, 2020 · 16 comments
Labels
Milestone

Comments

@josuemojena
Copy link


APPLICATION FAILED TO START


Description:

The bean 'requestMappingHandlerAdapter', defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/web/reactive/config/DelegatingWebFluxConfiguration.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

@dilipkrish
Copy link
Member

Not sure what's causing this. Does the error go away when you remove springfox-swagger2? Is this a spring boot app?

Would you be able to create a failing test or replicate it here fixed? so this can be fixed.

@ghost
Copy link

ghost commented Jun 25, 2020

Have the same issue. It's caused probably by the fact that people who had spring boot version below 2.2.X or below within their projects and were using springfox 3.0.0-SNAPSHOT after upgrade have spring-boot conflict. Springfox is using spring boot 2.3.1 now that's why there is such issue.
image

If someone is using only webflux stack then he should get above issue cause webmvc is included as well and there is a spring boot autoconfiguration conflict

@mfalowski
Copy link

springfox-* seems to use webmvc which causes problems on reactive stack. I've noticed you have made changes in that area recently c9b41dc#diff-4fe0b8294479ac5f5c20c7604ab4cece

@josuemojena
Copy link
Author

No estoy seguro de qué está causando esto. ¿El error desaparece cuando elimina springfox-swagger2? ¿Es esta una aplicación de arranque de primavera?

¿Sería capaz de crear una prueba fallida o replicarla aquí arreglada ? así que esto se puede arreglar.

Not sure what's causing this. Does the error go away when you remove springfox-swagger2? Is this a spring boot app?

Would you be able to create a failing test or replicate it here fixed? so this can be fixed.

Not sure what's causing this. Does the error go away when you remove springfox-swagger2? Is this a spring boot app?

Would you be able to create a failing test or replicate it here fixed? so this can be fixed.

The problem happens to me using spring boot 2.3.0 and springfox-swagger2:3.0.0-SNAPSHOT, once I remove the springfox dependency it works as it should.

@pmrocha-mindera
Copy link

you need to add

spring.main.web-application-type=reactive

to your application.properties

@josuemojena
Copy link
Author

josuemojena commented Jun 25, 2020

you need to add

spring.main.web-application-type=reactive

to your application.properties

Thanks, I solved that way, although it doesn't render the endpoints, it says the following:

"Unable to render this definition
The provided definition does not specify a valid version field.

Please indicate a valid Swagger or OpenAPI version field. Supported version fields are swagger: "2.0" and those that match openapi: 3.0.n (for example, openapi: 3.0.0)."

@pmrocha-mindera
Copy link

@josuemojena are you setting the DocumentationType.SWAGGER_2 when you initialize a new Docket?

@josuemojena
Copy link
Author

@josuemojena are you setting the DocumentationType.SWAGGER_2 when you initialize a new Docket?

Yes, I do.

@josuemojena
Copy link
Author

@josuemojena are you setting the DocumentationType.SWAGGER_2 when you initialize a new Docket?

Look at this.

image

@pmrocha-mindera
Copy link

@josuemojena try to downgrade to 2.10.5 and see if that solves your issue

@josuemojena
Copy link
Author

@pmrocha-mindera I can't, because it doesn't support webflux

@pmrocha-mindera
Copy link

@josuemojena it does, 2.10.5 is the latest stable version of the old 3.0.0 snapshot, as their are upgrading the snashopt and some things are in a W.I.P. state they released the 2.10.5

@dilipkrish
Copy link
Member

Thanks everyone for

Have the same issue. It's caused probably by the fact that people who had spring boot version below 2.2.X or below within their projects and were using springfox 3.0.0-SNAPSHOT after upgrade have spring-boot conflict. Springfox is using spring boot 2.3.1 now that's why there is such issue.
image

If someone is using only webflux stack then he should get above issue cause webmvc is included as well and there is a spring boot autoconfiguration conflict

This is an inadvertent change. I'll fix this. Thank you everyone for jumping in with the explanation! Y'all rock!🤘

@dilipkrish
Copy link
Member

If y'all are using spring boot, remove the explicit dependency on swagger2 and add just the dependency on springfox-boot-starter and remove any explicit annotations like @EnableSwagger2WebFlux etc. let me know if that is any better.

@josuemojena
Copy link
Author

@josuemojena it does, 2.10.5 is the latest stable version of the old 3.0.0 snapshot, as their are upgrading the snashopt and some things are in a W.I.P. state they released the 2.10.5

Thank you, that's how I solved my problem.

@dilipkrish
Copy link
Member

This should now be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants