Grails Spring 安全性 - 每当应用程序重新启动时,用户和角色表都会被擦除

Grails Spring Security - User and Role tables are wiped whenever the application restarts

我将用户详细信息存储在 MySQL 数据库中,但是每当应用程序重新启动时,所有用户和角色都会丢失。我最初以为是Bootstrap.groovy中的这一部分:

UserRole.withSession {
   it.flush()
   it.clear()
}

但是发表评论对情况没有任何影响。此外,当应用程序重新启动时,我对用户 table 所做的任何修改(附加字段)也会消失。因为我是 Grails 的新手,所以我还不知道我还能在哪里寻找这种行为来禁用它。这可能发生在哪些其他文件中?

看起来您的数据源配置中的 dbCreatecreate-drop(当应用程序完全关闭时它会删除表)。

将其更改为 update(创建缺失的表和索引,并在不删除任何表或数据的情况下更新当前模式)。

https://docs.grails.org/latest/guide/conf.html#_more_on_dbcreate