gpt4 book ai didi

grails - 升级到 Grails 2.4.4 的问题

转载 作者:行者123 更新时间:2023-12-02 07:18:52 28 4
gpt4 key购买 nike

从 Grails 2.4.3 升级到 2.4.4 后,启动 Grails 应用程序时不断出现错误。完整的错误可以在这里阅读:http://pastebin.com/UXQ34JKD

2014-10-31 16:26:32 ERROR [context.GrailsContextLoaderListener] Error initializing the application: 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 org.hibernate.MappingException: Association references unmapped class: java.util.List
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 org.hibernate.MappingException: Association references unmapped class: java.util.List
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: 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 org.hibernate.MappingException: Association references unmapped class: java.util.List
... 4 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: java.util.List
... 4 more
Caused by: org.hibernate.MappingException: Association references unmapped class: java.util.List
... 4 more

它显示了一个关联引用未映射的类:java.util.List

它没有说明什么域类或任何真正有用的信息。我尝试删除一些域类并试图找出原因,但它是大型应用程序,我没有成功。

任何人都可以为我指明正确的方向,以找出触发此问题的位置以及如何修复它吗?

最佳答案

找出问题所在

您需要做的第一件事是找出导致问题的字段。它可能是域类中声明为 List 的任何字段。

就我而言,很容易找到它们,因为该项目还处于早期阶段,并且没有太多的域。

但是,我发现了一个possible solution缩小可能的罪魁祸首范围。

有趣的部分是:

What sucks is the only good way to figure out where they are is to set a breakpoint on line 436 of AbstractGrailsDomainBinder and look at the state of affairs

解决问题

当您发现不正确的字段时,就该实现解决方法了。

假设我们的罪魁祸首是在域类中列出作者,例如:

class Book {
List<Integer> authors // keeps author ids
}

当然,我们需要删除该列表,因此解决方案如下:

class Book {

static transients = ['authors']

String authorIds

public void setAuthors(List<Integer> authorList) {
this.authorIds = authorList ? authorList.join(";") : ''
}

public List<Integer> getAuthors() {
return authorIds?.split(";")?.collect { it.toInteger() } ?: []
}

}

可能的副作用

我注意到需要显式调用 setter 才能工作。

我非常确定在以前的 Grails 版本中,以下代码会调用 setter:

new Book(authors: [1, 2, 3])

但看起来在 Grails 2.4.4 中需要这样做:

def book = new Book()
book.setAuthors([1, 2, 3])

关于grails - 升级到 Grails 2.4.4 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26682959/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com