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
+8-8
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ NOTE: At the moment, AOT is focused on allowing Spring applications to be deploy
36
36
We intend to support more JVM-based use cases in future generations.
37
37
38
38
[[aot.basics]]
39
-
== AOT engine overview
39
+
== AOT Engine Overview
40
40
41
41
The entry point of the AOT engine for processing an `ApplicationContext` is `ApplicationContextAotGenerator`. It takes care of the following steps, based on a `GenericApplicationContext` that represents the application to optimize and a {spring-framework-api}/aot/generate/GenerationContext.html[`GenerationContext`]:
42
42
@@ -225,7 +225,7 @@ When a `datasource` instance is required, a `BeanInstanceSupplier` is called.
225
225
This supplier invokes the `dataSource()` method on the `dataSourceConfiguration` bean.
226
226
227
227
[[aot.running]]
228
-
== Running with AOT optimizations
228
+
== Running with AOT Optimizations
229
229
230
230
AOT is a mandatory step to transform a Spring application to a native executable, so it
231
231
is automatically enabled when running in this mode. It is possible to use those optimizations
@@ -244,7 +244,7 @@ However, keep in mind that some optimizations are made at build time based on a
244
244
This section lists the best practices that make sure your application is ready for AOT.
245
245
246
246
[[aot.bestpractices.bean-registration]]
247
-
=== Programmatic bean registration
247
+
=== Programmatic Bean Registration
248
248
249
249
The AOT engine takes care of the `@Configuration` model and any callback that might be
250
250
invoked as part of processing your configuration. If you need to register additional
@@ -266,7 +266,7 @@ notion of a classpath. For cases like this, it is crucial that the scanning happ
266
266
build time.
267
267
268
268
[[aot.bestpractices.bean-type]]
269
-
=== Expose The Most Precise Bean Type
269
+
=== Expose the Most Precise Bean Type
270
270
271
271
While your application may interact with an interface that a bean implements, it is still very important to declare the most precise type.
272
272
The AOT engine performs additional checks on the bean type, such as detecting the presence of `@Autowired` members or lifecycle callback methods.
@@ -326,21 +326,21 @@ However, this is not a best practice and flagging the preferred constructor with
326
326
327
327
In case you are working on a code base that you cannot modify, you can set the {spring-framework-api}/beans/factory/support/AbstractBeanDefinition.html#PREFERRED_CONSTRUCTORS_ATTRIBUTE[`preferredConstructors` attribute] on the related bean definition to indicate which constructor should be used.
328
328
329
-
[[aot.bestpractices.comlext-data-structure]]
330
-
=== Avoid Complex Data Structure for Constructor Parameters and Properties
329
+
[[aot.bestpractices.complex-data-structures]]
330
+
=== Avoid Complex Data Structures for Constructor Parameters and Properties
331
331
332
332
When crafting a `RootBeanDefinition` programmatically, you are not constrained in terms of types that you can use.
333
333
For instance, you may have a custom `record` with several properties that your bean takes as a constructor argument.
334
334
335
335
While this works fine with the regular runtime, AOT does not know how to generate the code of your custom data structure.
336
336
A good rule of thumb is to keep in mind that bean definitions are an abstraction on top of several models.
337
-
Rather than using such structure, decomposing to simple types or referring to a bean that is built as such is recommended.
337
+
Rather than using such structures, decomposing to simple types or referring to a bean that is built as such is recommended.
338
338
339
339
As a last resort, you can implement your own `org.springframework.aot.generate.ValueCodeGenerator$Delegate`.
340
340
To use it, register its fully qualified name in `META-INF/spring/aot.factories` using the `Delegate` as the key.
341
341
342
342
[[aot.bestpractices.custom-arguments]]
343
-
=== Avoid Creating Bean with Custom Arguments
343
+
=== Avoid Creating Beans with Custom Arguments
344
344
345
345
Spring AOT detects what needs to be done to create a bean and translates that in generated code using an instance supplier.
346
346
The container also supports creating a bean with {spring-framework-api}++/beans/factory/BeanFactory.html#getBean(java.lang.String,java.lang.Object...)++[custom arguments] that leads to several issues with AOT:
0 commit comments