Grails Spring 安全插件 RC :3 shows error about table creation in development mode

标签 grails spring-security development-environment bootstrapping

我昨天升级到 Grails Spring Security Core Plugin RC:3,现在当我创建一些虚拟管理员用户(就像 Bootstrap 文件中文档的教程部分一样)时,在启动过程中我收到这些错误。我相信这些都可以,不会引起问题,但奇怪的是我不习惯用 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]

我不确定这些是否会被抛出,因为我正在使用内存数据库进行开发。

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
            }
        }
    }
}

最佳答案

我有看起来像 same problem 的内容虽然这是由于使用 hibernate4 插件引起的。我认为这并不严重,但我想停止启动时的额外日志记录,这样我就不会错过任何重要的事情。

我在 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

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

关于Grails Spring 安全插件 RC :3 shows error about table creation in development mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23872473/

相关文章:

64-bit - 用Vista 64编写的代码是否在32位操作系统上兼容?

linux - Yocto 项目中是否有任何 'Project File' 或 'Workspace file' 或 'Solution file' 等价物?

javascript - GSP 页面看起来没有被浏览器解释

mysql - 如何从 groovy-grails 中的 csv 文件更新 mysql 数据库?

post - chalice 3 : Binding multiple command objects via POST

java - 将 Spring Security 移至 Java Config,authentication-success-handler-ref 去哪儿了?

validation - Grails:重复项和唯一约束验证

java - 服务器重启后 HttpSession 仍然存在

java - 如果我使用Md5PasswordEncoder进行密码加密,如何在spring security配置中配置passwordEncoder?

linux - 虚拟化 Linux 是否足够快以用于软件开发?