Search code examples
javaspringaopcglib

spring aop FastClassBySpringCGLIB vs EnhancerBySpringCGLIB


I have got an exception stacktrace, see picture below, in the stacktrace, there are $$FastClassBySpringCGLIB$$ and $$EnhancerBySpringCGLIB$$(underscored by light red color), they are for the same DAO class, I have @Transactional and @DataSource(for switch datasource) on DAO method. what is the difference between Fast and Enhancer? why need both of them?

enter image description here


Solution

  • Your question is quite technical, so please forgive me if my answer is as well, pointing you to a nice unofficial CGLIB manual. There you can find all kinds of details about both Enhancer and FastClass. I will not quote them here.

    If you do not want to read the manual (which I would understand), all you need to know is that these are the internal workings of CGLIB or how Spring chooses to use it, respectively.