首页 \ 问答 \ 使用groovy-all jar运行Groovy脚本时,如何指定类路径?(When running Groovy scripts using the groovy-all jar, how do you specify a classpath?)

使用groovy-all jar运行Groovy脚本时,如何指定类路径?(When running Groovy scripts using the groovy-all jar, how do you specify a classpath?)

我找到了一个在没有使用groovy-all jar文件安装Groovy的系统上运行Groovy脚本的例子。 我尝试了以下内容:

java -cp src:.:lib/* -jar lib/groovy-all-2.0.1.jar src/com/example/MyScript.groovy

麻烦的是我的脚本依赖于lib目录中的jar以及另外两个位于src / com / examples中的Groovy脚本文件。 当我运行它时,它会抱怨所有这些导入语句。 我可以在安装了Groovy的系统上运行它,方法如下:

CLASSPATH="src:.:lib/*" groovy src/com/example/MyScript.groovy 

我如何以这种方式运行Groovy脚本,使用groovy-all jar以及给它一个类路径?


I've found an example for running Groovy scripts on systems that do not have Groovy installed using the groovy-all jar file. I attempted the following:

java -cp src:.:lib/* -jar lib/groovy-all-2.0.1.jar src/com/example/MyScript.groovy

The trouble is my script depends on jars in the lib directory plus two other Groovy script files located in src/com/examples. When I run this, it complains about the import statements for all of them. I can run it on a system that has Groovy installed fine by using the following:

CLASSPATH="src:.:lib/*" groovy src/com/example/MyScript.groovy 

How do I run Groovy scripts this way, using the groovy-all jar, as well as give it a classpath?


原文:https://stackoverflow.com/questions/12391985
更新时间:2022-05-14 12:05

最满意答案

你的方法是正确的,但是我建议限制你的Async只适用于生产,因为在开发中,Sprockets尚未将所有文件连接在一起。

<%= javascript_include_tag "application", async: Rails.env.production?, onload: 'pageScripts()' %>

Your approach is correct however I would suggest to limit your Async only for production since in development Sprockets hasn't concatinated all of the files yet.

<%= javascript_include_tag "application", async: Rails.env.production?, onload: 'pageScripts()' %>

相关问答

更多
  • 你的方法是正确的,但是我建议限制你的Async只适用于生产,因为在开发中,Sprockets尚未将所有文件连接在一起。 <%= javascript_include_tag "application", async: Rails.env.production?, onload: 'pageScripts()' %> Your approach is correct however I would suggest to limit your Async only for production since i ...
  • 通过添加一个async设置为true的 如果你真的不希望脚本在页面加载后执行,那么你也可以将代码包装在window.onload 。 这种方式下载脚本不会阻止页面的渲染,并且只有在页面加载后才会执行代码。 https://developers.google.com/web/fundamentals/performance/critical-rendering-path/adding-interactivity ...
  • 资料来源: https : //developer.tizen.org/dev-guide/2.2.1/org.tizen.web.appprogramming/html/tutorials/w3c_tutorial/storage_tutorial/app_cache_managing.htm 我会查看App缓存事件,尤其是updateready事件。 document.body.style.display = 'none'; //this should probably be in your style ...
  • 尝试jQuery.getScript函数。 Try jQuery.getScript function.
  • 尝试为脚本标记设置执行window.google_trackConversion()的onload回调