Require type-level @Controller annotation
Closes gh-22154
This commit is contained in:
@@ -1348,6 +1348,29 @@ directly to the response body versus view resolution and rendering with an HTML
|
||||
|
||||
|
||||
|
||||
[[webflux-ann-requestmapping-proxying]]
|
||||
==== AOP Proxies
|
||||
[.small]#<<web.adoc#mvc-ann-requestmapping-proxying, Web MVC>>#
|
||||
|
||||
In some cases, you may need to decorate a controller with an AOP proxy at runtime.
|
||||
One example is if you choose to have `@Transactional` annotations directly on the
|
||||
controller. When this is the case, for controllers specifically, we recommend
|
||||
using class-based proxying. This is automatically the case with such annotations
|
||||
directly on the controller.
|
||||
|
||||
If the controller implements an interface, and needs AOP proxying, you may need to
|
||||
explicitly configure class-based proxying. For example, with `@EnableTransactionManagement`
|
||||
you can change to `@EnableTransactionManagement(proxyTargetClass = true)`, and with
|
||||
`<tx:annotation-driven/>` you can change to `<tx:annotation-driven proxy-target-class="true"/>`.
|
||||
|
||||
NOTE: Keep in mind that as of 6.0, with interface proxying, Spring MVC no longer detects
|
||||
controllers based solely on a type-level `@RequestMapping` annotation on the interface.
|
||||
Please, enable class based proxying, or otherwise the interface must also have an
|
||||
`@Controller` annotation.
|
||||
|
||||
|
||||
|
||||
|
||||
[[webflux-ann-requestmapping]]
|
||||
=== Request Mapping
|
||||
[.small]#<<web.adoc#mvc-ann-requestmapping, Web MVC>>#
|
||||
|
||||
@@ -1512,17 +1512,23 @@ directly to the response body versus view resolution and rendering with an HTML
|
||||
|
||||
[[mvc-ann-requestmapping-proxying]]
|
||||
==== AOP Proxies
|
||||
[.small]#<<web-reactive.adoc#webflux-ann-requestmapping-proxying, WebFlux>>#
|
||||
|
||||
In some cases, you may need to decorate a controller with an AOP proxy at runtime.
|
||||
One example is if you choose to have `@Transactional` annotations directly on the
|
||||
controller. When this is the case, for controllers specifically, we recommend
|
||||
using class-based proxying. This is typically the default choice with controllers.
|
||||
However, if a controller must implement an interface that is not a Spring Context
|
||||
callback (such as `InitializingBean`, `*Aware`, and others), you may need to explicitly
|
||||
configure class-based proxying. For example, with `<tx:annotation-driven/>` you can
|
||||
change to `<tx:annotation-driven proxy-target-class="true"/>`, and with
|
||||
`@EnableTransactionManagement` you can change to
|
||||
`@EnableTransactionManagement(proxyTargetClass = true)`.
|
||||
using class-based proxying. This is automatically the case with such annotations
|
||||
directly on the controller.
|
||||
|
||||
If the controller implements an interface, and needs AOP proxying, you may need to
|
||||
explicitly configure class-based proxying. For example, with `@EnableTransactionManagement`
|
||||
you can change to `@EnableTransactionManagement(proxyTargetClass = true)`, and with
|
||||
`<tx:annotation-driven/>` you can change to `<tx:annotation-driven proxy-target-class="true"/>`.
|
||||
|
||||
NOTE: Keep in mind that as of 6.0, with interface proxying, Spring MVC no longer detects
|
||||
controllers based solely on a type-level `@RequestMapping` annotation on the interface.
|
||||
Please, enable class based proxying, or otherwise the interface must also have an
|
||||
`@Controller` annotation.
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user