很多时候我得到像这样的堆栈跟踪(请参阅箭头中的混淆线):
org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [PRIMARY]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:164)
at org.springframework.orm.hibernate5.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:741)
at org.springframework.orm.hibernate5.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:589)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
---------> at com.panpwr.admin.services.detector.SimpleDetectorPersistenceService$$EnhancerBySpringCGLIB$$66303639.saveComplexRuleAndActionTemplates(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
...
...
...
$$标志是什么,以及&#39;生成的是什么?意味着在这一行?
com.panpwr.admin.services.detector.SimpleDetectorPersistenceService$$EnhancerBySpringCGLIB$$66303639.saveComplexRuleAndActionTemplates(<generated>)
为什么它只说执行的方法而不是它中的行呢?
答案 0 :(得分:20)
$
是类名中允许的字符。
名称SimpleDetectorPersistenceService$$EnhancerBySpringCGLIB$$66303639
暗示它是一个由Spring框架在运行时使用CGLIB动态生成的类。
他们使用$$
和数字偏移量使此类名称唯一,以避免与现有类冲突。
stracktrace中的字符串(<generated>)
也是由CGLIB生成的:
当CGLIB在运行时创建一个类时,它使用<generated>
作为源文件名的占位符。然后,堆栈跟踪只是打印此字符串而不是真实的源文件和行号。