-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Open
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: waiting-for-triageAn issue we've not yet triaged or decided onAn issue we've not yet triaged or decided on
Description
We like having interfaces define a contract for beans, and we also like having things like auto-configuration.
However, we can have situations where we know we only want there to ever be one implementation of an interface in the bean registry.
As a developer or perhaps even ops, I want to have duplicate bean definitions caught early instead of at the @Autowired site.
Would it work to either have something like:
package com.acme;
@UniqueBean
interface MyBean {
}or
application.yml
spring:
unique-beans:
- com.acme.MyBeanWe could then get a different exception thrown for this scenario, and and a far simpler exception report than the NoUniqueBeanDefinitionException report which is often not the information that is best to diagnose the cause of the duplication.
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: waiting-for-triageAn issue we've not yet triaged or decided onAn issue we've not yet triaged or decided on