Skip to content

Autowired fields in Converter class #30255

@officialpatterson

Description

@officialpatterson

Hi,

I have a spring boot project which relies on a custom converter class to convert between types. This class is annotated with @Component.

Previously this converter worked perfectly fine and all it did was map between the fields of one type to the fields of another type. However I've now got the problem where requires another spring component (a field has a non-linear mapping between types so we require this external service to get the correct mapping); we'll call this mappingService.

As a result it no longer works and I get a converter not found exception. I have tried constructor injection, and field injection and same bad result. I also tried setter injection and the converter was found but the mappingService was null.

I find this pretty peculiar as mappingService works as its injected elsewhere in the app but it can't be injected into the converter

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: stackoverflowA question that's better suited to stackoverflow.comstatus: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions