grails - Grails 4:@GrailsCompileStatic 注释不起作用
问题描述
从 grails 3.3.5 迁移 -> grails 4.0.0.M2
我的类已经用@GrailsCompileStatic
& 进行了注释,它在 3.3.5 中编译时没有任何问题。
许多其他类也显示由 groovy 额外提供的方法的错误,例如Date.parse()
orDate.format()
或Date.minus()
错误:
FileCommandReader.groovy: 163: [Static type checking] - Cannot find matching method java.util.Date#parse(java.lang.String, java.lang.String). Please check if the declared type is correct and if the method exists.
@ line 163, column 17.
Date expiry = Date.parse("HH:mm:ss", cols[2]);
解决方案
这真的不是@GrailsCompileStatic
问题。Grails 4.0 使用 Groovy 2.5.6。以下代码无法使用 Groovy 2.5.6 编译...
import groovy.transform.CompileStatic
@CompileStatic
class Helper {
void someMethod() {
Date.parse '', ''
}
}
Grails 3.3.5 使用 Groovy 2.4.15,上面的代码在 Groovy 2.4.15 中有效。
推荐阅读
- python-3.x - 使用 to_csv 将 Excel 文件转换为 csv,即使单元格被格式化为字符串,也会删除前导零
- postgresql - PostgreSQL 返回和 sql 元组描述不兼容
- javascript - express.static() 不路由静态文件
- c++ - 尝试从另一个进程读取 32 位整数时,ReadProcessMemory 崩溃应用程序
- r - 如何为 R 中另一个数据帧的每个 ID 复制数据帧的所有行?
- database - 自动化和重命名 Azure 数据库的问题
- html - 在不添加图像的情况下制作多色背景的最佳方法是什么?
- node.js - 更新mongodb数据不删除旧数据
- python - KDE 方法对多模态更敏感
- jquery - 图像之间的猫头鹰轮播过渡