when will the class get proxied by SpringCGLB

Viewed 19

I can sometimes get the annotation via [object].getClass().isAnnotationPresent([Annotation.class]) but sometimes not. So I turn on the debug mode and find the difference: In the fist picture, b.getClass() return the actual class: stan.beans.HisBean enter image description here But in the second picture, it actually return something different, looks like a modified class by Spring framework so I use the proxied word in the title: class packagepath.Handler$$EnhancerBySpringCGLIB$$da96cafa

enter image description here

Thanks to @Teppic I figure out we can use AopProxyUtils.ultimateTargetClass() to get the non-proxied class

But my question now is :

When will SpringCGLB proxy the class? Is there any configuration I can change? Cause I think both my screenshots use the same configuration. They almost shadow each other.

Important Info Thanks to @M. Deinum The second bean class(proxied one) has Spring Cache @Cacheable annotation on some methods

0 Answers
Related