简体   繁体   English

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

[英]Java compile error in Ant: using class literals in annotations

I have the following Java annotation on a class (it's for a myBatis plugin): 我在类上有以下Java注释(它是myBatis插件):

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

It compiles and works fine in Eclipse, but when trying to run an Ant build script, I get the following error: 它在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

I've tried fully qualifying the classes used in the annotation, but that results in the same error. 我已经尝试完全限定注释中使用的类,但这会导致相同的错误。 Any thoughts on what I'm doing wrong? 对我做错了什么的想法?

Thanks. 谢谢。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM