【问题标题】:Configuring Hibernate with grails使用 grails 配置 Hibernate
【发布时间】:2014-06-20 08:18:37
【问题描述】:

我创建了一个 Grails 应用程序并创建了 Spring Security 插件设置到它。

当我运行应用程序时,出现以下错误。休眠文件夹为空。谁能帮我解决这个问题?

2014-06-20 13:41:26,946 [http-bio-8080-exec-21] ERROR [/GrailsLoginWithSpring].[gsp]  - 
Servlet.service() for servlet [gsp] in context with path [/GrailsLoginWithSpring] threw exception
Message: org.springframework.beans.factory.BeanCreationException: 

Error creating bean with name 'org.grails.internal.SESSION_FACTORY_HOLDER': 
Cannot create inner bean '(inner bean)#3720a15d' of type 
[org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean] 
while setting bean property 'sessionFactory'; 
nested exception is org.springframework.beans.factory.BeanCreationException: 

Error creating bean with name '(inner bean)#3720a15d': Invocation of init method failed; 
nested exception is java.io.FileNotFoundException: class path resource [hibernate.cfg.xml] 
cannot be resolved to URL because it does not exist

【问题讨论】:

    标签: java spring hibernate grails


    【解决方案1】:

    尝试添加

    hibernate {
      reload = false
    }
    

    正如 Graeme Rocher 在 JIRA 中所建议的那样

    【讨论】:

    • 您好 gotomanners 感谢您的回复,但我仍然得到以下错误。调用 init 方法失败;嵌套异常是 java.io.FileNotFoundException:类路径资源 [hibernate.cfg.xml] 无法解析为 URL,因为它不存在
    • 您的解决方案成功了 gotomanners。我运行了多个 Java 实例,因此代码更改没有反映出来。谢谢!再做一个小的澄清。直到我需要一个自定义的休眠功能,我才需要在 grails 中创建一个 hibernate.cfg.xml。我的理解对吗?
    • @9000492 很高兴这对您有所帮助!是的,我还没有使用过自定义的 hibernate,所以我从来没有使用过 hibernate.cfg.xml。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-13
    • 1970-01-01
    • 2017-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多