From b0fc2fe473414324732393fad44172390577e19d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 21 Aug 2023 12:32:45 +0200 Subject: [PATCH] Document destroy method inference more prominently Closes gh-29546 --- .../ROOT/pages/core/beans/factory-nature.adoc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/core/beans/factory-nature.adoc b/framework-docs/modules/ROOT/pages/core/beans/factory-nature.adoc index e3a1204295..c23676f938 100644 --- a/framework-docs/modules/ROOT/pages/core/beans/factory-nature.adoc +++ b/framework-docs/modules/ROOT/pages/core/beans/factory-nature.adoc @@ -247,14 +247,17 @@ Kotlin:: 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 `` element a special -`(inferred)` value, which instructs Spring to automatically detect a public `close` -or `shutdown` method on the specific bean class. (Any class that implements -`java.lang.AutoCloseable` or `java.io.Closeable` would therefore match.) You can also -set this special `(inferred)` value on the `default-destroy-method` attribute of a -`` element to apply this behavior to an entire set of beans (see +Note that Spring also supports inference of destroy methods, detecting a public `close` or +`shutdown` method. This is the default behavior for `@Bean` methods in Java configuration +classes and automatically matches `java.lang.AutoCloseable` or `java.io.Closeable` +implementations, not coupling the destruction logic to Spring either. + +TIP: For destroy method inference with XML, you may assign the `destroy-method` attribute +of a `` 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 `` 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]). -Note that this is the default behavior for `@Bean` methods in Java configuration classes. [NOTE] ====