advancedSpring Internals — Bean Lifecycle & Proxies
How does Spring decide between JDK Dynamic Proxy and CGLIB, and what production issues can that choice introduce?
JDK proxy requires the bean to implement an interface (the proxy implements that interface); CGLIB creates a runtime subclass and is used when there's no interface, or when proxyTargetClass=true (Spring Boot's default). CGLIB proxies can't proxy final classes/methods, and calling a proxied method from within the same class (self-invocation) bypasses either proxy type entirely.
This is a Pro question
Sign in, then upgrade to Pro or Power to unlock this question and the full Interview Prep bank.
How does Spring decide between JDK Dynamic Proxy and CGLIB, and what production issues can that choice introduce?