Skip to content

Emit log message when multiple primary beans are detected #35550

@peastham-nflx

Description

@peastham-nflx

Overview

In DefaultListableBeanFactory::determinePrimaryCandidate(...), it is possible for multiple @Primary beans to be resolved.

If the calling code ignores the NoUniqueBeanDefinitionException (I'm unsure if I can make a simple reproduction of this easily), the oversight can be hidden to the developer.

Could a log mirroring the exception message be included?

I'm unsure what Log Level would be best, but it would be useful.

Spring Framework 6.2.11

Before writing this, I checked the debugging experience by setting logging.level.org.springframework.beans: trace and setting a break point in the @Bean declaration.

That was not enough information to see why a specific bean was resolving, hence the request here.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions