spring-projects / spring-projects/spring-hateoas
Problem with muliple ObjectMapper and WebFluxHateoasConfiguration.HypermediaWebFluxConfigurer.hypermediaWebFluxConfigurer(...)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
We have to deal with multiple named ObjectMappers in our Application.
Using @EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL) leads to the following Exception:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hypermediaWebFluxConfigurer' defined in class path resource [org/springframework/hateoas/config/WebFluxHateoasConfiguration.class]: Failed to instantiate [org.springframework.hateoas.config.WebFluxHateoasConfiguration$HypermediaWebFluxConfigurer]: Factory method 'hypermediaWebFluxConfigurer' threw exception with message: No qualifying bean of type 'com.fasterxml.jackson.databind.ObjectMapper' available: expected single matching bean but found 2: customizedObjectMapperAAA,customizedObjectMapperBBB
I did not find a possibility to hook into the configuration to use a specific ObjectMapper. The only way to workaround this problem is to use the @Primary annotation to select the preferred ObjectMapper bean.
Is there a way to configure the ObjectMapper? If not it would be nice to have such a possibility to do so.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with WebFluxHateoasConfiguration and its HypermediaWebFluxConfigurer.hypermediaWebFluxConfigurer(...) factory method, which currently fails when two named ObjectMapper beans exist. Determine how configuration could select a specific mapper, then verify the chosen configuration works with multiple ObjectMapper beans without requiring @Primary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100