Jdbc Groovy不读取.Groovy/lib中的jar文件

Jdbc Groovy不读取.Groovy/lib中的jar文件,jdbc,groovy,classpath,Jdbc,Groovy,Classpath,我对jar文件和groovy有问题。对于一些特定的示例,我尝试连接到postgresql数据库,并在使用 sql=sql.newInstance(“jdbc:postgresql://localhost“,”用户“,”通行证“,”org.postgresql.Driver“) 我得到org.postgresql.Driver的ClassNotFound异常。我在${user.home}/.groovy/lib中有postgresqljar,groovy-starter.conf中要从那里加载的行

我对jar文件和groovy有问题。对于一些特定的示例,我尝试连接到postgresql数据库,并在使用
sql=sql.newInstance(“jdbc:postgresql://localhost“,”用户“,”通行证“,”org.postgresql.Driver“)
我得到org.postgresql.Driver的ClassNotFound异常。我在${user.home}/.groovy/lib中有postgresqljar,groovy-starter.conf中要从那里加载的行没有注释掉。我在dbunit.jar文件中也遇到了类似的问题

如果我尝试使用groovy-cp手动添加类路径,我会得到一个错误
catch:java.io.UnsupportedEncodingException:p


有什么想法吗?

根据CLI帮助-:

$groovy-帮助
用法:groovy
-a、 --自动拆分自动拆分当前行
(默认为“\s”)
-c、 --编码指定文件的编码
-e指定命令行脚本
-h、 --帮助使用信息
-我在适当的地方修改文件
-l监听端口并处理入站线路
-n逐行处理文件
-p逐行处理文件并打印结果
-v、 --版本显示Groovy和JVM版本
groovy-cp
将告诉
groovy
加载不存在的characterset
p

假设您使用了
${user.home}/.groovy/lib
的正确路径,那么您尝试使用
${user.home}/.groovy/lib
时应该是有效的。如果你在操作系统上添加信息,我们可能会看到你是否正确

作为WA-只需将
CLASSPATH
环境变量导出到JAR所在的任何位置

Windows:
设置CLASSPATH=c:\temp\postgresql.jar;c:\temp\dbunit.jar…

Unix/Linux(KSH):
导出类路径=${HOME}/temp/postgresql.jar:${temp}/temp/dbunit.jar…

您能发布
java.io.UnsupportedEncodingException
的完整堆栈跟踪吗?
$groovy -help
usage: groovy
 -a,--autosplit <splitPattern>   automatically split current line
                                 (defaults to '\s')
 -c,--encoding <charset>    specify the encoding of the files
 -e <script>               specify a command line script
 -h,--help                 usage information
 -i <extension>            modify files in place
 -l <port>                 listen on a port and process inbound lines
 -n                        process files line by line
 -p                        process files line by line and print result
 -v,--version              display the Groovy and JVM versions