首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Grails忽略hibernate.cfg.xml

Grails忽略hibernate.cfg.xml
EN

Stack Overflow用户
提问于 2010-09-28 14:08:24
回答 1查看 1.3K关注 0票数 3

实际上,我在两个tomcat实例上部署了grails应用程序。现在我遇到了一个问题。我的石英作业需要聚集。

我阅读了插件文档,发现了将Quartz作业与数据库结合在一起的可能性。

因此,我必须在grails应用程序中创建hibernate映射('grails-app/conf/hibernate/hibernate.cfg.xml')。

代码语言:javascript
复制
<?xml version='1.0' encoding='UTF-8'?>

代码语言:javascript
复制
<session-factory>
    <mapping resource='Quartz.hbm.xml'/>
</session-factory>

然后,我还创建了一个Quartz.hbm.xml。这个为Quartz插件创建表。

启动应用程序时,grails似乎没有使用hibernate.cfg.xml,也没有创建表。

我的想法是,问题是我的定义如下。

代码语言:javascript
复制
import org.apache.commons.dbcp.BasicDataSource
import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH

// Place your Spring DSL code here
beans = {
  dataSource(BasicDataSource) { bean ->
    bean.destroyMethod = 'close'
    def ds = CH.config.dataSource
    // required attributes
    if(ds.driverClassName == "com.mysql.jdbc.Driver") {
      url = ds.url
      username = ds.username
      password = ds.password
      driverClassName = ds.driverClassName
      // optional attributes
      minEvictableIdleTimeMillis = 1000 * 60 * 30
      timeBetweenEvictionRunsMillis = 1000 * 60 * 30
      numTestsPerEvictionRun = 3
      testOnBorrow = true
      testWhileIdle = false
      testOnReturn = false
      initialSize = 2
      minIdle = 1
      maxIdle = 4
      validationQuery = "SELECT NOW()"
    } else {
      url = ds.url
      username = ds.username
      password = ds.password
      driverClassName = ds.driverClassName
    }
  }
}

现在我有了hibernate日志的输出。文件似乎会被解释。但是在解析之后发生了什么呢?日志中没有例外。

代码语言:javascript
复制
2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver  - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver  - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver  - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver  - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver  - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
2010-09-29 11:30:39,852 [main] DEBUG org.hibernate.util.DTDEntityResolver  - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
2010-09-29 11:30:39,868 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration  - null <- org.dom4j.tree.DefaultAttribute@1374ffd [Attribute: name resource value "Quartz.hbm.xml"]
2010-09-29 11:30:39,868 [main] DEBUG org.hibernate.cfg.AnnotationConfiguration  - null <- org.dom4j.tree.DefaultAttribute@1374ffd [Attribute: name resource value "Quartz.hbm.xml"]
2010-09-29 11:30:39,868 [main] INFO  org.hibernate.cfg.Configuration  - Reading mappings from resource : Quartz.hbm.xml
2010-09-29 11:30:39,868 [main] INFO  org.hibernate.cfg.Configuration  - Reading mappings from resource : Quartz.hbm.xml
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver  - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver  - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver  - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver  - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver  - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
2010-09-29 11:30:39,884 [main] DEBUG org.hibernate.util.DTDEntityResolver  - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
2010-09-29 11:30:39,930 [main] INFO  org.hibernate.cfg.Configuration  - Configured SessionFactory: null
2010-09-29 11:30:39,930 [main] INFO  org.hibernate.cfg.Configuration  - Configured SessionFactory: null

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2010-09-28 20:41:29

这句话让我很困惑

,然后我还创建了一个Quartz.hbm.xml。这个为Quartz插件创建表。

我认为您应该使用特定于数据库的src/templates/sql目录中提供给您的映射文件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3813622

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档