2

尝试运行命令grails run-app --stacktrace时,grails 抛出此错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.ClassCastException: org.grails.datastore.mapping.model.MappingFactory$10 cannot be cast to org.grails.datastore.mapping.model.types.ToMany

static hasMany从所有域类中发表了评论,但错误仍然存​​在,直到我我的build.gradle

如何使用hibernate4解决这个问题?

4

2 回答 2

0

我找到了解决方案,实际上它与embedded grails domain property.

于 2016-05-19T12:06:10.993 回答
0

正如@deepen 提到的,此错误与嵌入式域类的映射设置有关。就我而言,我使用的是多个数据库(mongodb gorm 6.0.12 + jtds (sql server)),并且一些文档具有嵌入式属性(在同一类中定义)。

DomainA.groovy
class DomainA
    static hasMany = [domainBs: DomainB]
    static embedded = ['domainBs']
    static mapWith = "mongo"

class DomainB
    // if embedded: what's the point of this? 
    static belongsTo = [domainB: DomainA]
    // if i'll use it as embedded, doesn't add nothing
    static mapWith = "mongo"

简而言之,如果我在嵌入式类的定义中发表评论,问题就解决了belongsTomapWith如果没有,必须记住mapWith嵌入类与容器类具有相同的数据源。

于 2018-01-16T14:05:29.010 回答