我正在将Grails 2.4.4应用程序升级到Grails 2.5.0,并且我遇到了之前编写的测试的一些问题。应用程序本身运行正常,但是当我运行“grails test-app”时,我多次得到以下异常:
java.lang.NoClassDefFoundError: grails/gorm/TestCriteriaBuilder
at grails.test.mixin.domain.TestGormStaticApi.createCriteria(DomainClassUnitTestMixin.groovy:199)
at org.grails.datastore.gorm.validation.constraints.UniqueConstraint.processValidate_closure1(UniqueConstraint.groovy:69)
at org.grails.datastore.gorm.validation.constraints.UniqueConstraint.withManualFlushMode_closure2(UniqueConstraint.groovy:109)
at org.grails.datastore.gorm.GormStaticApi.withSession_closure22(GormStaticApi.groovy:687)
at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:302)
at org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:37)
at org.grails.datastore.gorm.GormStaticApi.withSession(GormStaticApi.groovy:686)
at org.grails.datastore.gorm.validation.constraints.UniqueConstraint.withManualFlushMode(UniqueConstraint.groovy:104)
at org.grails.datastore.gorm.validation.constraints.UniqueConstraint.processValidate(UniqueConstraint.groovy:39)
at org.grails.datastore.gorm.GormValidationApi.doValidate(GormValidationApi.groovy:64)
at org.grails.datastore.gorm.GormValidationApi.validate(GormValidationApi.groovy:145)
at org.grails.datastore.gorm.GormInstanceApi.doSave(GormInstanceApi.groovy:172)
at org.grails.datastore.gorm.GormInstanceApi.save_closure5(GormInstanceApi.groovy:162)
at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:302)
at org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:37)
at org.grails.datastore.gorm.GormInstanceApi.save(GormInstanceApi.groovy:161)
at org.grails.datastore.gorm.GormInstanceApi.save(GormInstanceApi.groovy:101)
尝试清洁和重建没有成功。我也试过升级到2.4.5,结果相同,我使用的是最新的塑料标准插件,但这似乎不是一个因素。有线索吗? 感谢
答案 0 :(得分:4)
在将我的应用程序从2.4.3升级到2.4.5后执行单元测试时遇到了同样的异常。我在BuildConfig中手动添加了包含测试范围的包:
runtime 'org.grails:grails-datastore-gorm:3.1.4.RELEASE'
它有效。您可以根据您正在使用的Grails更改版本。