Document destroy method inference more prominently
Closes gh-29546
This commit is contained in:
parent
2952cb95f5
commit
b0fc2fe473
|
|
@ -247,14 +247,17 @@ Kotlin::
|
||||||
|
|
||||||
However, the first of the two preceding definitions does not couple the code to Spring.
|
However, the first of the two preceding definitions does not couple the code to Spring.
|
||||||
|
|
||||||
TIP: You can assign the `destroy-method` attribute of a `<bean>` element a special
|
Note that Spring also supports inference of destroy methods, detecting a public `close` or
|
||||||
`(inferred)` value, which instructs Spring to automatically detect a public `close`
|
`shutdown` method. This is the default behavior for `@Bean` methods in Java configuration
|
||||||
or `shutdown` method on the specific bean class. (Any class that implements
|
classes and automatically matches `java.lang.AutoCloseable` or `java.io.Closeable`
|
||||||
`java.lang.AutoCloseable` or `java.io.Closeable` would therefore match.) You can also
|
implementations, not coupling the destruction logic to Spring either.
|
||||||
set this special `(inferred)` value on the `default-destroy-method` attribute of a
|
|
||||||
`<beans>` element to apply this behavior to an entire set of beans (see
|
TIP: For destroy method inference with XML, you may assign the `destroy-method` attribute
|
||||||
|
of a `<bean>` element a special `(inferred)` value, which instructs Spring to automatically
|
||||||
|
detect a public `close` or `shutdown` method on the bean class for a specific bean definition.
|
||||||
|
You can also set this special `(inferred)` value on the `default-destroy-method` attribute
|
||||||
|
of a `<beans>` element to apply this behavior to an entire set of bean definitions (see
|
||||||
xref:core/beans/factory-nature.adoc#beans-factory-lifecycle-default-init-destroy-methods[Default Initialization and Destroy Methods]).
|
xref:core/beans/factory-nature.adoc#beans-factory-lifecycle-default-init-destroy-methods[Default Initialization and Destroy Methods]).
|
||||||
Note that this is the default behavior for `@Bean` methods in Java configuration classes.
|
|
||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue