Hi, It is becoming harder and harder to use self-injection: - Spring boot 2.6 forbids it by default: https://github.com/spring-projects/spring-boot/issues/27652 - spring boot 2.6.4 broke @SpyBean: https://github.com/spring-projects/spring-boot/issues/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.
https://github.com/spring-projects/spring-boot/issues/27652#issuecomment-1090771850 recommended to raise an issue to the framework team.
Is there an official documented strategy and list of legitimate use cases for self-injection ? https://github.com/spring-projects/spring-framework/issues/27534#issuecomment-938632203 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