Skip to content

BeanPostProcessor bean declaration that retrieves object from injected ObjectFactory with bounded type parameter results in missing PluginRegistry bean during application startup #1210

Open
@sprd-tovo

Description

@sprd-tovo

Given:

  • a Spring-Boot project
  • using Spring-HATEOAS

When:

  • there is a BeanPostProcessor bean declaration
  • which gets an ObjectFactory with bounded type parameter injected
  • where getObject() is called on the injected ObjectFactory

Then:

  • application startup fails with error Parameter 0 of method _relProvider in org.springframework.hateoas.config.HateoasConfiguration required a bean of type 'org.springframework.plugin.core.PluginRegistry' that could not be found..

The following example bean declaration will cause the error:

@Bean
public BeanPostProcessor exampleBeanPostProcessor(ObjectFactory<? extends ExampleComponent> exampleComponentObjectFactory) {
    exampleComponentObjectFactory.getObject();
    return new BeanPostProcessor() {};
}

Any of the following alterations to the bean declaration will avoid the error:

  • using a non-bounded type parameter
  • not calling getObject() on the ObjectFactory
  • declaring a bean of a type not BeanPostProcessor

Complete error message:

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method _relProvider in org.springframework.hateoas.config.HateoasConfiguration required a bean of type 'org.springframework.plugin.core.PluginRegistry' that could not be found.

The following candidates were found but could not be injected:
	- User-defined bean method 'relProviderPluginRegistry' in 'HateoasConfiguration'


Action:

Consider revisiting the entries above or defining a bean of type 'org.springframework.plugin.core.PluginRegistry' in your configuration.

Minimal example project: https://github.com/VTLob/spring-hateoas-issue

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions