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
Application does not start due to two bean instances of org.springframework.plugin.core.PluginRegistry (Follow-up) #1094
Comments
Having very similar issue after upgrading spring boot to 2.2.0 APPLICATION FAILED TO START Description: Parameter 0 of method linkDiscoverers in org.springframework.hateoas.config.HateoasConfiguration required a single bean, but 17 were found: Action: Consider marking one of the beans as @primary, updating the consumer to accept multiple beans, or using @qualifier to identify the bean that should be consumed |
Agree using spring-boot-starter-hateoas version 2.2.0.RELEASE get same error. Please fix this! org.springframework.data spring-data-releasetrain Moore-RELEASE import pomand springfox 2.9.2 |
Same here after migration to Spring-Boot 2.2.0.RELEASE. |
+1 Would like to a see a solution for this error please |
The workaround I have at the moment is to remove all |
@chadmalla-ff also facing the same issue. APPLICATION FAILED TO START Description: Parameter 0 of method linkDiscoverers in org.springframework.hateoas.config.HateoasConfiguration required a single bean, but 16 were found: Action: Consider marking one of the beans as @primary, updating the consumer to accept multiple beans, or using @qualifier to identify the bean that should be consumed. Please provide inputs if you find any solution to this issue. |
@chadmalla-ff it is not an option to remove all springfox deps |
@rainer198 Understand making beans primary or such. But which beans to override from HateoasConfiguration? |
The community has identified springfox on the classpath as the key factor. Thanks for doing that. How do you propose we test any potential changes? We don’t want to add springfox to this project since this project does nothing with that project. |
@gregturn Understand it should be the springfox community who is responsible to be compatible with latest Spring Boot 2.2.0.RELEASE and it's subprojects. But while googling this it appears in your community. |
@gregturn The reason to the error is that springfox uses an earlier version of spring-plugin which is not compatible with spring-hateoas which uses 2.0.0.RELEASE of the plugin. Tried to workaround this but realized it is not possible until springfox releases a new version using the latest spring-plugin version. |
I'm going to label this as invalid, since the real issue is that Spring HATEAOS is not presently compatible with Springfox (based on older versions of Spring Plugin and Spring Framework). Feel free to track efforts on Springfox. |
Sorry, have not been in office for a couple of days and missed the discussion here. I do not agree that this is related to spring fox. I don't have spring fox on the classpath and can reproduce the issue. The issue is that Spring HATEOAS relies on Spring autowiring fallback. If multiple candidate beans are found (here: multiple PluginRegistry beans) to be injected into another bean as constructor argument (here: relProvider), then Spring tries to guess the correct canidate by comparing bean names with constructor argument name. If any canidate matches this one is chosen. However, it is possible to turn off this fallback in a spring application. One way is to set the
Doing this, the fallback mechanism is not able to resolve constructor arguments and can't decide for a candidate. Instead, an exception is thrown. Turning off the fallback is a valid configuration in our opinion if you want to avoid autowiring the wrong instance of a bean by chance. The term "fallback" is also used by Spring (see Fixing this on Spring HATEOAS side is pretty simple. Each PluginRegistry bean should have explicit names (e.g. |
Hi guys, does anyone has a workaround for this? I would like to update my springboot app to 2.2.1 so we can use delayed instantiation feature. Thanks |
@rainer198 That's an awfully quirky solution. It implies that you shouldn't use autowiring anywhere.
Take away Spring HATEOAS and instead look at any Spring application, and explain why we shouldn't presume we can do this. If there are two |
It's not me needing more than one but you ;-)
So, Spring HATEOAS instantiates two PluginRegistry beans, and the only way autowiring works here is based on a fallback based on parameter names. In our application this fallback has been turned off for reasons (we have a lot of beans of same interface, in our application and we wanted to force developers to explicitly state in a constructor which bean to use.) |
I have a similar issue. But I run into it when using spring-cloud-dataflow-rest-client and spring-boot-starter-test together.
It seems to be something in spring-boot-starter-test that automatically loads all beans of a type. |
Hi, I am facing the same issue after trying to upgrade a project that relies on both Springfox and HATEOAS from Spring Boot 2.1 to Spring Boot 2.2. I see that @rainer198 suggested a solution within HATEOAS on October 30th. The ticket was then closed and the discussion fizzled out. But the problem remains. Could @rainer198 's suggestion be incorporated into HATEOAS, @gregturn, or do you have any other suggestion on how this could be resolved (other than not upgrading at all or removing one of HateOAS or Springfox)? If I am forced to remove a library, it will most likely be HATEOAS as Springfox provides essential self-documentation of the REST API in the project. Thanks |
I'm in the same boat as @chrisgleissner. If there's any chance this can be addressed in HateOAS as per @rainer198 's suggestion that woul dbe great. Otherwise, I'll also have to remove HateOAS from my application for the same reasons as @chrisgleissner. Thanks in hopefulness. |
Today I've faced the same problem.
|
I ended up replacing springfox with the better maintained springdoc-openapi-ui.
Problem solved.
…On Thu, Mar 19, 2020, 10:09 Yurii Chekhotskyi ***@***.***> wrote:
Today I've faced the same problem.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1094 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA6JA6ZEPAP33OCN5KGQPHTRIHOLXANCNFSM4JBYSWEQ>
.
|
@chrisgleissner we did the same |
I had the same issue but after adding this dependency everything is working
|
I did following workaround to avoid spring Hateoas startup issue
|
I am facing the same problem |
Add into SwaggerConfig
|
Great! You're right! |
This is #1094 (comment) is the actual good solution along with |
As @SimonHasak did, I solve this problem adding the dependency of spring core too.
|
Worked for me too. Thanks. |
Following the same approach, but I just upgraded SpringFox version to |
Thank you very much |
As explained in the last comment of #966 , an application using
spring-hateoas-1.0.0
does not start if the bean factory is setup in a way that theParameterNameDiscoverer
is null or an alternative implementation.The reason is that when autowiring of
PluginRegistry
into the bean_relProvider
it finds two candidates and choosing one soley relies on the constructor argument name (same inEntityLinksConfiguration
where the other instance ofPluginRegistry
is created.)This could be easily resolved by using
@Qualifier
annotations and named beans.The text was updated successfully, but these errors were encountered: