-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
Hi,
It is becoming harder and harder to use self-injection:
- Spring boot 2.6 forbids it by default: Prohibit circular references by default spring-boot#27652
- spring boot 2.6.4 broke @SpyBean: @SpyBean and @Transactional and SelfInjection regression in 2.6.4 spring-boot#30575
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