为什么Gorm不能识别Grails 4中的mongo域类



Grails 4.0.10。Mongodb 5.0.9社区。

我正在遵循上的说明https://gorm.grails.org/latest/mongodb/manual/Grails插件项目。

第一个异常,build.gradle:

compile 'org.grails.plugins:mongodb:7.3.0'

一旦我这样做,我会得到依赖性错误,还必须添加

compile 'org.mongodb:mongodb-driver-core:4.7.0'
compile 'org.mongodb:mongodb-driver-sync:4.7.0'

好吧,其他的都是一个普通的项目。我创建了一个测试域类";QtxResponse";作为

@Entity
class QtxResponse {
static mapWith = "mongo"
String objectId
static constraints = {
}
static mapping = {
//id column: "object_id"
objectId index: true
}
}

项目顺利启动。使用控制台,我通过创建具有String objectId属性的域类创建了一个新的QtxResponse,并尝试保存它

java.lang.IllegalStateException: Either class [domainobject.qualtrics.QtxResponse] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.

这告诉我什么?这是Gorm设置的问题还是映射到mongodb的问题?我试过使用和不使用Hibernate。

对于Grails 4.0.10,此配置(与hibernate一起(有效:

compile 'org.grails.plugins:mongodb:6.1.7'
compile 'org.mongodb:bson:4.7.0'
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.4.0.Final"
compile "org.hibernate:hibernate-ehcache:5.1.3.Final"

最新更新