Skip to content

When @DependsOn throws a NoSuchBeanDefinitionException it should include the dependent bean for clarity [SPR-16628] #21169

@spring-projects-issues

Description

@spring-projects-issues

Kyle Anderson opened SPR-16628 and commented

When a bean annotated with @DependsOn references a bean name that doesn't exist, a NoSuchBeanDefinitionException is thrown.

Example:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myMissingBean' available

I think this exception can be improved to contain information pertaining to the bean that was annotated with @DependsOn.

Example:

org.springframework.beans.factory.NoSuchBeanDefinitionException: 'com.example.MyBean' depends on a bean named 'myMissingBean' but it wasn't available

This would add a little extra clarity and traceability.


Affects: 4.3.14, 5.0.4

Reference URL: #1751

Backported to: 4.3.15

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions