在 Grails 中,我无法覆盖默认错误消息

In Grails, I cannot override the default error message

class User {
     String userName
     static constraints = {
        userName nullable:false
     }
}

*** I tried the different combination of the following in the message.properties ***
User.userName.null.message=The User Name cannot be null/blank
User.userName.null=The User Name cannot be null/blank
[package].User.userName.null.message=The User Name cannot be null/blank 
[package].User.userName.null=The User Name cannot be null/blank 

但还是没有运气。我仍然收到默认错误消息“属性[userName] of clas[package_name] cannot be null. I'm using Grails 3.0.8

关键是user.userName.nullable。在您的资源包中使用以下条目。

user.userName.nullable=Your custom text