Grails测试和@Transactional

时间:2012-09-17 16:21:32

标签: testing grails transactions

我有Grails测试:

class GormTests extends GroovyTestCase {
   static transactional = false
   ...
}

我正在尝试通过org.springframework.transaction.annotation.Transactional注释将方法标记为事务性但是出现以下异常:

org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class GormTests]: Common causes of this problem include using a final class or a non-visible class; nested exception is net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null

我该如何解决?

1 个答案:

答案 0 :(得分:2)

@Transactional仅适用于Spring bean - 测试类不是bean。最好的办法是将测试类分成两部分,一部分是非事务性测试,一部分是。