使用新的 Groovy Grape 功能会导致“无法解析类” 错误
我尝试在 Groovy 1.6-beta-2 中使用新的 Groovy Grape 功能,但出现错误信息;
unable to resolve class com.jidesoft.swing.JideSplitButton
运行普通示例时,从 Groovy 控制台 (/opt/groovy/groovy-1.6-beta-2/bin/groovyConsole) ;
import com.jidesoft.swing.JideSplitButton
@Grab(group='com.jidesoft', module='jide-oss', version='[2.2.1,)')
public class TestClassAnnotation {
public static String testMethod () {
return JideSplitButton.class.name
}
}
我什至尝试运行葡萄命令行工具以确保导入库。 像这样;
$ /opt/groovy/groovy-1.6-beta-2/bin/grape install com.jidesoft jide-oss
这确实可以很好地安装库。 如何从 groovyConsole 正确运行/编译代码?
I've tried to use the new Groovy Grape capability in Groovy 1.6-beta-2 but I get an error message;
unable to resolve class com.jidesoft.swing.JideSplitButton
from the Groovy Console (/opt/groovy/groovy-1.6-beta-2/bin/groovyConsole) when running the stock example;
import com.jidesoft.swing.JideSplitButton
@Grab(group='com.jidesoft', module='jide-oss', version='[2.2.1,)')
public class TestClassAnnotation {
public static String testMethod () {
return JideSplitButton.class.name
}
}
I even tried running the grape command line tool to ensure the library is imported. Like this;
$ /opt/groovy/groovy-1.6-beta-2/bin/grape install com.jidesoft jide-oss
which does install the library just fine. How do I get the code to run/compile correctly from the groovyConsole?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
在制定启动/终止开关例程时仍然存在一些问题。 对于 Beta-2,首先在它自己的脚本中执行此操作:
您将遇到的另一个问题涉及使用无界上限的乐趣。 Jide-oss 从 2.3.0 开始一直将其代码编译为 Java 6 字节码,因此您需要在 Java 6 中运行控制台(无论如何,这正是您想要为 Swing 做的事情)或设置上限范围,像这样
There is still some kinks in working out the startup/kill switch routine. For Beta-2 do this in it's own script first:
Another issue you will run into deals with the joys of using an unbounded upper range. Jide-oss from 2.3.0 onward has been compiling their code to Java 6 bytecodes, so you will need to either run the console in Java 6 (which is what you would want to do for Swing anyway) or set an upper limit on the ranges, like so
我终于让它适用于 Groovy Shell(1.6.5,JVM:1.6.0_13)。 这应该被更好地记录下来。
首先在命令行...
然后在 groovysh 中...
@grab 在文件中使用比在 shell 中使用更好。
I finally got it working for Groovy Shell (1.6.5, JVM: 1.6.0_13). This should be documented better.
First at the command line...
Then in groovysh...
The @grab is better used in a file than the shell.
好的。 看起来这是一个简短的工作演示(从 groovyConsole 运行),
运行时会产生
结果:“com.jidesoft.swing.JideSplitButton”
非常酷!
Ok. Seems like this a short working demo (running from the groovyConsole)
When run it produces
Result: "com.jidesoft.swing.JideSplitButton"
Very cool!!
导入语句必须出现在抓取之后。
诗。 抓取后必须至少存在一个导入语句
The import statement must appear after the grabs.
Ps. At least one import statement must exists after the grabs
使用最新 RC-2 的不同示例(注意:Grab 注释 createEmptyInts):
Different example using latest RC-2 (note: Grab annotates createEmptyInts):
另一个例子(注:Grab注释了getHtml):
Another example (note: Grab annotates getHtml):
另一个例子(注意:
Grab
注释了getFruit
):Another example (note:
Grab
annotatesgetFruit
):