如何在不使用-cp开关的情况下自动加载Groovy中的数据库jar? [英] How do I auto load a database jar in Groovy without using the -cp switch?
问题描述
我想简化对调用Oracle数据库的Groovy脚本的执行。如何将ojdbc jar添加到默认的classpath中以便我可以运行:
groovy RunScript.groovy
而不是:
groovy -cp ojdbc5.jar RunScript.groovy
摘要来自Scott Davis的 Groovy Recipes ,自动在./groovy/lib目录中包含JAR :
- 在您的登录目录中创建
.groovy / lib
取消$ {GROOVY_HOME } /conf/groovy-starter.conf
load!{user.home} /。groovy / lib / *。jar $ c
将您想要包含的罐子复制到
.groovy / lib
对于Groovy 1.5或更高版本,默认情况下(无需编辑conf),只需将jar放入/ lib目录。
I want to simplify my execution of a Groovy script that makes calls to an Oracle database. How do I add the ojdbc jar to the default classpath so that I can run:
groovy RunScript.groovy
instead of:
groovy -cp ojdbc5.jar RunScript.groovy
Summarized from Groovy Recipes, by Scott Davis, Automatically Including JARs in the ./groovy/lib Directory:
- Create
.groovy/lib
in your login directory Uncomment the following line in ${GROOVY_HOME}/conf/groovy-starter.conf
load !{user.home}/.groovy/lib/*.jar
Copy the jars you want included to
.groovy/lib
It appears that for Groovy 1.5 or later you get this by default (no need to edit the conf), just drop the jars in the /lib dir.
这篇关于如何在不使用-cp开关的情况下自动加载Groovy中的数据库jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!