如何将 Grails 中域字段的默认设置更改为可为空

发布于 2024-09-07 20:10:25 字数 20 浏览 1 评论 0原文

我希望任何字段默认可为空。

I want any field to be nullable in default.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凉墨 2024-09-14 20:10:25

如果您使用的是 1.2+,您可以将以下内容放入 grails-app/conf/Config.groovy

grails.gorm.default.constraints = {
    '*'(nullable:true,blank:true)
}

You can place the following in grails-app/conf/Config.groovy if you are using 1.2+

grails.gorm.default.constraints = {
    '*'(nullable:true,blank:true)
}
一身骄傲 2024-09-14 20:10:25

来自此处

可空、空白和其他 gorm 约束的默认值可以是
通过添加如下代码片段在 Config.groovy 中进行配置:

grails.gorm.default.constraints = {
    '*'(nullable:true,blank:true)
} 

From here

The defaults for nullable, blank and the other gorm constraints can be
configured in Config.groovy by adding a snippet such as:

grails.gorm.default.constraints = {
    '*'(nullable:true,blank:true)
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文