-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Overview
Due to interest from the community (see comments in #33602), we have decided to reinstate support for overriding non-singleton beans via the Bean Override mechanism -- for example, when using @MockitoBean
, @MockitoSpyBean
, and @TestBean
.
Rationale
When #33602 was raised, our Bean Override support always created a "pseudo" bean definition for each overridden bean. That caused problems in general but especially for AOT support.
While implementing AOT support, we stopped registering pseudo bean definitions for existing bean definitions (see commits 461f172 and 5ddeb06).
And in conjunction with #33800 we relaxed the restrictions for singleton enforcement even further (see commit 81d89f4).
Consequently, it should now be possible to support Bean Overrides for non-singletons, for both standard JVM and AOT runtimes. However, we should document that non-singletons will effectively be converted to singletons when overridden, and we should log a warning as well.