Skip to content

Auto-resolve bean name conflicts for scanned classes [SPR-14665] #19229

Closed as not planned
@spring-projects-issues

Description

@spring-projects-issues

Caleb Cushing opened SPR-14665 and commented

so let's say I have two WebSecurityConfig classes which extend WebSecurityConfigurerAdapter. You will get a conflict like this

nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'webSecurityConfig' for bean class [com.xenoterracide.rpf.security.config.WebSecurityConfig] conflicts with existing, non-compatible bean definition of same name and class [com.xenoterracide.rpf.config.WebSecurityConfig]

this of course would be even worse if they were in jars you didn't control the source for (not that I've ever encountered that).

It occurs to me that I never need to use name injection for these. Perhaps spring could auto name them including the package name... or some other unique method (or perhaps do away with the name requirement?). Basically the idea is if you want a user friendly name to inject that you can still specify one.

This probably does break backwards compatibility so maybe it could be part of 5 if possible.


Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions