Grails 4&quot“静态类型检查”仅对日期对象错误
因此,我从Grails 3.3.x迁移到4.0.13。当我尝试编译我的应用程序时,当我尝试使用任何日期属性的格式
方法时,我会遇到编译错误。对于Exmaple
class Event {
Date startDateTime
Date regDeadline
}
,然后在我的GSON课程中,
model {
Event event
}
json {
eventDate event.startDateTime.format("MM/dd/yyyy hh:mm a")
regDeadline event.regDeadline.format("MM/dd/yyyy hh:mm a")
}
我有以下编译错误
Exception in thread "main" org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
raa_domain_grid__event_gson: 10: [Static type checking] - Cannot find matching method java.util.Date#format(java.lang.String). Please check if the declared type is correct and if the method exists.
@ line 10, column 15.
eventDate event.startDateTime.format("MM/dd/yyyy hh:mm a")
^
raa_domain_grid__event_gson: 11: [Static type checking] - Cannot find matching method java.util.Date#format(java.lang.String). Please check if the declared type is correct and if the method exists.
@ line 11, column 17.
regDeadline event.regDeadline.format("MM/dd/yyyy hh:mm a")
,以前没有问题。我怀疑这与Groovy升级到2.5.6有关,但我看不到这个问题是什么。这在我整个应用程序中都在发生。当我尝试将格式应用于它们时,我所有具有日期为属性的课程都会引发此错误。以上只是一个简单的例子。
So I am migrating from Grails 3.3.x to 4.0.13. When I try to compile my app I am getting compilation errors when I try to use the format
method for any Date property. For exmaple
class Event {
Date startDateTime
Date regDeadline
}
Then in my GSON class I have this
model {
Event event
}
json {
eventDate event.startDateTime.format("MM/dd/yyyy hh:mm a")
regDeadline event.regDeadline.format("MM/dd/yyyy hh:mm a")
}
I get the following compiling error
Exception in thread "main" org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
raa_domain_grid__event_gson: 10: [Static type checking] - Cannot find matching method java.util.Date#format(java.lang.String). Please check if the declared type is correct and if the method exists.
@ line 10, column 15.
eventDate event.startDateTime.format("MM/dd/yyyy hh:mm a")
^
raa_domain_grid__event_gson: 11: [Static type checking] - Cannot find matching method java.util.Date#format(java.lang.String). Please check if the declared type is correct and if the method exists.
@ line 11, column 17.
regDeadline event.regDeadline.format("MM/dd/yyyy hh:mm a")
This worked without issues before. I suspect it has something to do with the Groovy upgrade to 2.5.6 but I don't see what that issue would be. This is happening throughout my entire app. All my Classes that have Dates as properties throw this error when I try to apply formatting to them. The above is just a simple example of that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
刚刚发现,在Groovy 2.5中删除了日期助手方法,并将其放入另一个库
groovy-dateutil
。通过将其添加到我的gradle构建文件中,所有内容都按预期编译。Just found that the Date helper methods were removed in Groovy 2.5 and put into another library
groovy-dateutil
. By adding this to my Gradle build file everything compiled as expected.