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

Use ObjectProvider to inject RequestMappingInfoHandlerMapping #1282

Merged
merged 1 commit into from
Oct 8, 2021
Merged

Use ObjectProvider to inject RequestMappingInfoHandlerMapping #1282

merged 1 commit into from
Oct 8, 2021

Conversation

hisener
Copy link
Contributor

@hisener hisener commented Oct 4, 2021

We noticed failures in some Spring Boot tests in the Springdoc 1.5.11 upgrade PR.

In v1.5.11, SwaggerWelcomeWebMvc injects an optional RequestMappingInfoHandlerMapping, however it's possible to have multiple beans for that type. For instance, it's not uncommon to have ControllerEndpointHandlerMapping in addition to RequestMappingHandlerMapping.

This change uses ObjectProvider instead so that we can handle multiple beans.

The exception we get:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'swaggerWelcome' defined in class path resource [org/springdoc/webmvc/ui/SwaggerConfig.class]: Unsatisfied dependency expressed through method 'swaggerWelcome' parameter 3; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping' available: expected single matching bean but found 3: requestMappingHandlerMapping,webEndpointServletHandlerMapping,controllerEndpointHandlerMapping

Relates to #1258 and 6e709c9.

@shami13
Copy link

shami13 commented Oct 5, 2021

Hi @hisener
Do you know some workaround for this issue, until it not merged and released new version?
Regards, Mykhailo

@hisener
Copy link
Contributor Author

hisener commented Oct 6, 2021

I think you could provide a SwaggerWelcomeWebMvc bean. So that it won't create the one in SwaggerConfig since it has @ConditionalOnMissingBean annotation.

We decided to stick with 1.5.10 until a fix is merged and released.

@bnasslahsen
Copy link
Collaborator

@hisener,

Thank you for your contribution !

@bnasslahsen bnasslahsen merged commit e1d9f10 into springdoc:master Oct 8, 2021
@hisener hisener deleted the hsener/request-mapping-info-handler-mapping branch October 8, 2021 08:15
@bnasslahsen
Copy link
Collaborator

bnasslahsen commented Oct 20, 2021

@hisener,

I have made an adjustment to this PR, as ObjectProvider.orderedStream, breaks the compatibility with some dependent spring4 applications.
You can validate it on your side using the latest snapshot

@bnasslahsen bnasslahsen added the enhancement New feature or request label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants