预计''是一个内联常量。 Java - > Groovy的 [英] Expected ' ' to be an inline constant. Java -> Groovy

查看:723
本文介绍了预计''是一个内联常量。 Java - > Groovy的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  @Retention(RetentionPolicy.RUNTIME)
public @interface ScriptManifest {

/ **
*设置脚本宣传模式。
* @return ScriptMode
* /
ScriptMode mode();

/ **
*设置我们正在使用的脚本的类型。
* @return ScriptType
* /
Class <?扩展ScriptContext> [] type();

/ **
*设置脚本的名称。
* @return name
* /
String script_name();

/ **
*设置脚本的作者。
* @return author
* /
String author();






创建测试脚本,我的IntelliJ显示错误Expected 'ScriptMode.PUBLIC'是一个内联常量和TestContext.class相同。脚本函数运行正常,我只是不确定为什么它会显示这个给我,就好像它是一个错误。

  @ScriptManifest(mode = ScriptMode.PUBLIC,type = TestContext.class,script_name =Test,author =Jake)
class Test扩展脚本{

@Override
void prepare(){
printlnno+ getName()
}

}


解决方案

修正了以下问题:我试图在我的Maven项目中使用javac编译它,我添加了一个新的groovy模块并编译它与groovyc,它现在工作正常。


I am using a custom annotation in my groovy script:

    @Retention(RetentionPolicy.RUNTIME)
    public @interface ScriptManifest {

/**
 * Sets the scripts publicity mode.
 * @return ScriptMode
 */
ScriptMode mode();

/**
 * Sets the type of script we are using.
 * @return ScriptType
 */
Class<? extends ScriptContext>[] type();

/**
 * Sets the name of the script.
 * @return name
 */
String script_name();

/**
 * Sets the author of the script.
 * @return author
 */
String author();

}

Creating the test script, my IntelliJ shows the error " Expected 'ScriptMode.PUBLIC' to be an inline constant" and same for TestContext.class. The script functions and runs fine I just am not sure as to why it is showing this for me as if it is an error.

@ScriptManifest(mode = ScriptMode.PUBLIC, type = TestContext.class, script_name = "Test", author = "Jake")
class Test extends Script {

@Override
void prepare() {
    println "no" + getName()
}

}

解决方案

Fixed the issue doing the following: I was trying to compile it in my Maven project with the javac, I added a new groovy module and compiled it with groovyc and it works fine now.

这篇关于预计''是一个内联常量。 Java - &gt; Groovy的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆