Grails Spring Security插件RC:3显示有关在开发模式下创建表的错误 [英] Grails Spring Security Plugin RC:3 shows error about table creation in development mode

查看:111
本文介绍了Grails Spring Security插件RC:3显示有关在开发模式下创建表的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天升级到Grails Spring Security Core插件RC:3,现在当我在Bootstrap文件中创建一些虚拟Admin用户(如文档的文档部分)时,在启动过程中出现这些错误。我相信这些还可以,并且不会引起任何问题,但是很奇怪,我不习惯使用RC:2

I upgraded to Grails Spring Security Core Plugin RC:3 yesterday and now when I create some dummy Admin users just like the tutorial section of the documentation in my Bootstrap file, during the startup I get these Errors. I believe these are okay and shouldn't cause issues but it's strange that I didn't used to get these with RC:2

ERROR hbm2ddl.SchemaExport  - HHH000389: Unsuccessful: alter table user_role drop constraint FK_it77eq964jhfqtu54081ebtio if exists
Error |
2014-05-26 10:27:59,403 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport  - Table "USER_ROLE" not found; SQL statement:
alter table user_role drop constraint FK_it77eq964jhfqtu54081ebtio if exists [42102-173]

I由于我使用内存数据库进行开发,因此不确定是否抛出了这些错误。

I'm not sure these are thrown since I'm using the in-memory DB for development.

DataSource.groovy

dataSource {
    pooled = true
    jmxExport = true
    driverClassName = "org.h2.Driver"
    username = "sa"
    password = ""
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
//    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
    cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
    singleSession = true // configure OSIV singleSession mode
}

// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
            url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
        }
    }
    test {
        dataSource {
            dbCreate = "update"
            url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
        }
    }
    production {
        dataSource {
            dbCreate = "update"
            url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
            properties {
               // See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
               jmxEnabled = true
               initialSize = 5
               maxActive = 50
               minIdle = 5
               maxIdle = 25
               maxWait = 10000
               maxAge = 10 * 60000
               timeBetweenEvictionRunsMillis = 5000
               minEvictableIdleTimeMillis = 60000
               validationQuery = "SELECT 1"
               validationQueryTimeout = 3
               validationInterval = 15000
               testOnBorrow = true
               testWhileIdle = true
               testOnReturn = false
               jdbcInterceptors = "ConnectionState"
               defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
            }
        }
    }
}


推荐答案

我遇到了相同的问题,尽管它是由使用hibernate4插件引起的。我不认为这很严重,但是我想停止启动时的额外记录,这样我就不会错过任何重要的事情。

I had what looks like the same problem although it was caused by using the hibernate4 plugin. I don't think it's serious, but I wanted to stop the extra logging on startup so I wouldn't miss anything important.

我在src / groovy中创建了此类。

I created this class in src/groovy

package com.example

import org.hibernate.dialect.H2Dialect;

public class ImprovedH2Dialect extends H2Dialect {
    @Override
    public String getDropSequenceString(String sequenceName) {
        return "drop sequence if exists " + sequenceName;
    }

    @Override
    public boolean dropConstraints() {
        return false;
    }
}

并将此行添加到conf / DataSource.groovy

and added this line to conf/DataSource.groovy

environments {
    development {
        dataSource {
        dialect = com.example.ImprovedH2Dialect
            // ....
        }
    }
    // ....
}

这篇关于Grails Spring Security插件RC:3显示有关在开发模式下创建表的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆