项目中需要对系统执行的SQL语句进行拦截,需要使用到Java注解:
@Intercepts({@Signature(type = StatementHandler.class, method = "query", args = {Statement.class, ResultHandler.class}),
@Signature(type = StatementHandler.class, method = "update", args = {Statement.class}),
@Signature(type = StatementHandler.class, method = "batch", args = {Statement.class})})
系统使用Scala语言开发,直接使用编译报错,怎么转换成Scala格式的呢
这时候需要借助Array,并采用构造对象的方式进行编写,结果如下:
@Intercepts(Array(new Signature (`type` = classOf[StatementHandler], method = "query", args = Array(classOf[Statement], classOf[ResultHandler[Object]])),
new Signature (`type` = classOf[StatementHandler], method = "update", args = Array(classOf[Statement])),
new Signature (`type` = classOf[StatementHandler], method = "batch", args = Array(classOf[Statement]))))
这样就可以使用了。