gpt4 book ai didi

grails - Grails 3.1.0.RC1如何获取sessionFactory?

转载 作者:行者123 更新时间:2023-12-02 13:55:24 25 4
gpt4 key购买 nike

我将项目从grails 3.0.11迁移到grails 3.1.0.RC1并收到错误

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:698) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1175) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
... 48 common frames omitted

我能做什么?谢谢

最佳答案

我不知道3.1.X,但是在2.4.X和3.0.11中,我使用的是这样的:

def grailsApplication = Holders.getGrailsApplication()
def sessionFactory = grailsApplication?.mainContext?.sessionFactory

这在单元测试中不起作用,但是那时我不需要 session 工厂。它确实适用于开发,生产和集成测试。

关于grails - Grails 3.1.0.RC1如何获取sessionFactory?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34678293/

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