如何在不使用-cp开关的情况下自动加载Groovy中的数据库jar? [英] How do I auto load a database jar in Groovy without using the -cp switch?

查看:122
本文介绍了如何在不使用-cp开关的情况下自动加载Groovy中的数据库jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想简化对调用Oracle数据库的Groovy脚本的执行。如何将ojdbc jar添加到默认的classpath中以便我可以运行:

  groovy RunScript.groovy 

而不是:

  groovy -cp ojdbc5.jar RunScript.groovy 


解决方案

摘要来自Scott Davis的 Groovy Recipes 自动在./groovy/lib目录中包含JAR


  1. 在您的登录目录中创建 .groovy / lib
  2. 取消$ {GROOVY_HOME } /conf/groovy-starter.conf

    load!{user.home} /。groovy / lib / *。jar

  3. 将您想要包含的罐子复制到 .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:

  1. Create .groovy/lib in your login directory
  2. Uncomment the following line in ${GROOVY_HOME}/conf/groovy-starter.conf

    load !{user.home}/.groovy/lib/*.jar

  3. 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屋!

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