How do I auto load a database jar in Groovy without using the -cp switch?

后端 未结 5 1079
既然无缘
既然无缘 2020-12-03 00:12

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:

<         


        
5条回答
  •  旧时难觅i
    2020-12-03 00:34

    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.

提交回复
热议问题