spring-projects / spring-projects/spring-ai
ObjectMapper with @Primary annotation causing Exception
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 5
Description
When including the dependency:
org.springframework.ai:spring-ai-starter-model-openai:1.1.0-M4
I get the following exception:
No qualifying bean of type 'com.fasterxml.jackson.databind.ObjectMapper' available: more than one 'primary' bean found among candidates: [jacksonObjectMapper, objectMapper]
I was not able to track down where spring ai is really defining the a primary objectMapper bean, but this is the first time encountering this behaviour in any spring starter.
I know i can just reuse the objectmapper, but what if another project does the same thing? Then they are incompatible.
It would be great if you could remove this annotation and replace it with @ConditionalOnMissingBean
Contributor guide
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 the spring-ai-starter-model-openai:1.1.0-M4 configuration that registers the ObjectMapper beans, tracing the source of the primary bean mentioned in the exception. Reproduce startup with another primary ObjectMapper and verify that the dependency no longer causes the duplicate-primary failure while its own configuration remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100