CGLIB 问题

发布时间 2023-08-31 18:25:47作者: 正怒月神

全部错误信息如下:(为了大家能搜到,拼了,全部截下来~)

[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [protected final org.hibernate.Session org.springframework.orm.hibernate5.support.HibernateDaoSupport.currentSession() throws org.springframework.dao.DataAccessResourceFailureException] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.
[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [public final org.hibernate.SessionFactory org.springframework.orm.hibernate5.support.HibernateDaoSupport.getSessionFactory()] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.
[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [public final void org.springframework.orm.hibernate5.support.HibernateDaoSupport.setSessionFactory(org.hibernate.SessionFactory)] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.
[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [protected final void org.springframework.orm.hibernate5.support.HibernateDaoSupport.checkDaoConfig()] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.
[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [public final void org.springframework.orm.hibernate5.support.HibernateDaoSupport.setHibernateTemplate(org.springframework.orm.hibernate5.HibernateTemplate)] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.
[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [public final org.springframework.orm.hibernate5.HibernateTemplate org.springframework.orm.hibernate5.support.HibernateDaoSupport.getHibernateTemplate()] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.
[main] WARN org.springframework.aop.framework.CglibAopProxy - Unable to proxy interface-implementing method [public final void org.springframework.dao.support.DaoSupport.afterPropertiesSet() throws java.lang.IllegalArgumentException,org.springframework.beans.factory.BeanInitializationException] because it is marked as final: Consider using interface-based JDK proxies instead!
[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [public final void org.springframework.dao.support.DaoSupport.afterPropertiesSet() throws java.lang.IllegalArgumentException,org.springframework.beans.factory.BeanInitializationException] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.
[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [protected final org.hibernate.Session org.springframework.orm.hibernate5.support.HibernateDaoSupport.currentSession() throws org.springframework.dao.DataAccessResourceFailureException] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.
[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [public final org.hibernate.SessionFactory org.springframework.orm.hibernate5.support.HibernateDaoSupport.getSessionFactory()] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.
[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [public final void org.springframework.orm.hibernate5.support.HibernateDaoSupport.setSessionFactory(org.hibernate.SessionFactory)] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.
[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [protected final void org.springframework.orm.hibernate5.support.HibernateDaoSupport.checkDaoConfig()] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs against uninitialized fields in the proxy instance.
[main] INFO org.springframework.aop.framework.CglibAopProxy - Final method [public final void org.springframework.orm.hibernate5.support.HibernateDaoSupport.setHibernateTemplate(org.springframework.orm.hibernate5.HibernateTemplate)] cannot get proxied via CGLIB: Calls to this method will NOT be routed to the target instance and might lead to NPEs again

单元测试总是起不来(10分钟后能起来,但是调试下一步也非常慢!),一直在重复上面的错误信息。

针对这个问题,找了一下午!

说一下我的解决方案:

调试时,查看所有断点,然后把Java Exception Breakpoints取消选中!