Skip to content

Clarify recommendation on self-injection for legitimate use cases (e.g. @Transactional re-entrant calls) #28299

@jonenst

Description

@jonenst

Hi,
It is becoming harder and harder to use self-injection:

There are probably more small issues like this. However, unlike more general dependency cycles, self-injection seems to be considered a legitimate strategy for some use cases (e.g. @Transactional, @Cacheable re-entrant calls ) by many.

spring-projects/spring-boot#27652 (comment) recommended to raise an issue to the framework team.

Is there an official documented strategy and list of legitimate use cases for self-injection ? #27534 (comment) for example recommends @Lazy.
Or are there other implementation strategies that can be used to replace self-injection in these use cases?
My personal interest is purely reentrant calls from service beans on @Transactional methods.

This issue could be used to track documentation fixes to clarify these common use cases.

Thanks in advance

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions