Ant中的Java编译错误:在注释中使用类文字

时间:2011-10-31 17:38:09

标签: java ant annotations compiler-errors javac

我在类上有以下Java注释(它是myBatis插件):

@Intercepts({ @Signature(type = ResultSetHandler.class, method = "handleResultSets", args = (Statement.class)) })
public class MyResultSetHandlerPlugin implements Interceptor {
    //do stuff...
}

它在Eclipse中编译并运行良好,但在尝试运行Ant构建脚本时,我收到以下错误:

[javac] C:CLIP_PoC\src\com\lmig\am\claims\clip\MyPResultSetHandlerPlugin.java:27: annotation value must be a class literal
    [javac] @Intercepts({ @Signature(type = ResultSetHandler.class, method = "handleResultSets", args = (Statement.class)) })
    [javac]                                                                                             ^
    [javac] 1 error

我已经尝试完全限定注释中使用的类,但这会导致相同的错误。对我做错了什么的想法?

感谢。

1 个答案:

答案 0 :(得分:2)

如果您尝试将项目数组作为注释参数传递,则需要使用花括号而不是括号来指示该项目是数组。

@Intercepts({ @Signature(type = ResultSetHandler.class, method = "handleResultSets", args = {Statement.class}) })