You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: framework-docs/modules/ROOT/pages/core/aot.adoc
+7
Original file line number
Diff line number
Diff line change
@@ -256,6 +256,13 @@ Java::
256
256
257
257
If you are registering bean definitions programmatically, consider using `RootBeanBefinition` as it allows to specify a `ResolvableType` that handles generics.
258
258
259
+
[[aot.bestpractices.constructors]]
260
+
=== Avoid Multiple Constructors
261
+
The container is able to choose the most appropriate constructor to use based on several candidates.
262
+
However, this is not a best practice and flagging the preferred constructor with `@Autowired` if necessary is preferred.
263
+
264
+
In case you are working on a code base that you can't modify, you can set the {api-spring-framework}/beans/factory/support/AbstractBeanDefinition.html#PREFERRED_CONSTRUCTORS_ATTRIBUTE[`preferredConstructors` attribute] on the related bean definition to indicate which constructor should be used.
0 commit comments