From 2f262afc5151b7c77028123784b5a0e98bf2056c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 6 Aug 2025 21:11:07 +0200 Subject: [PATCH] Add documentation section on proxy type defaults and @Proxyable See gh-35286 See gh-35296 --- .../modules/ROOT/pages/core/aop/proxying.adoc | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/framework-docs/modules/ROOT/pages/core/aop/proxying.adoc b/framework-docs/modules/ROOT/pages/core/aop/proxying.adoc index 58d150a4c8d..429e5d6e7ef 100644 --- a/framework-docs/modules/ROOT/pages/core/aop/proxying.adoc +++ b/framework-docs/modules/ROOT/pages/core/aop/proxying.adoc @@ -28,6 +28,10 @@ you can do so. However, you should consider the following issues: deploying on the module path. Such cases require a JVM bootstrap flag `--add-opens=java.base/java.lang=ALL-UNNAMED` which is not available for modules. + +[[aop-forcing-proxy-types]] +== Forcing Specific AOP Proxy Types + To force the use of CGLIB proxies, set the value of the `proxy-target-class` attribute of the `` element to true, as follows: @@ -60,6 +64,24 @@ To be clear, using `proxy-target-class="true"` on ``, proxies _for all three of them_. ==== +`@EnableAspectJAutoProxy`, `@EnableTransactionManagement` and related configuration +annotations offer a corresponding `proxyTargetClass` attribute. These are collapsed +into a single unified auto-proxy creator too, effectively applying the _strongest_ +proxy settings at runtime. As of 7.0, this applies to individual proxy processors +as well, for example `@EnableAsync`, consistently participating in unified global +default settings for all auto-proxying attempts in a given application. + +The global default proxy type may differ between setups. While the core framework +suggests interface-based proxies by default, Spring Boot may - depending on +configuration properties - enable class-based proxies by default. + +As of 7.0, forcing a specific proxy type for individual beans is possible through +the `@Proxyable` annotation on a given `@Bean` method or `@Component` class, with +`@Proxyable(INTERFACES)` or `@Proxyable(TARGET_CLASS)` overriding any globally +configured default. For very specific purposes, you may even specify the proxy +interface(s) to use through `@Proxyable(interfaces=...)`, limiting the exposure +to selected interfaces rather than all interfaces that the target bean implements. + [[aop-understanding-aop-proxies]] == Understanding AOP Proxies