[karate] [standalone]错误:找不到或读取文件 [英] [karate][standalone] Error : could not find or read file

查看:90
本文介绍了[karate] [standalone]错误:找不到或读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仅使用最新的独立空手道罐子在配置有JRE的docker容器上测试我的API,并且我没有任何Java代码.

I am only using the latest standalone karate jar to test my API on a docker container configured with JRE and I don't have any Java code.

当前我的一项功能是:read('file.json'), 当资源文件与功能文件位于同一目录时,它可以正常工作.我知道建议这样做.

Currently on one of my features, i have this : read('file.json'), and it works fine when the resource file is on the same directory than the feature file. I know that it is recommended to do this way.

但是,如果我还想拥有一个包含所有资源文件的中央目录,以避免重复, 即使使用此命令也不起作用: read('classpath:directory/file.json')

But if i also want to have a central directory with all resource files to avoid duplicatas, it doesn't work even with this command : read('classpath:directory/file.json')

错误如下:

"[[com.intuit.karate.exception.KarateException:找不到或读取文件:xxx,前缀:CLASSPATH"

"[com.intuit.karate.exception.KarateException: could not find or read file: xxx, prefix: CLASSPATH"

在运行jar时,我什至尝试在命令行上设置类路径也没有成功: java -cp $CLASSPATH . -jar ~/karate.jar

I even tried without success to set a classpath on the command line when running the jar : java -cp $CLASSPATH . -jar ~/karate.jar

我的问题:是否可以使用独立的jar在空手道上设置前缀,以便能够轻松地从其他目录读取任何文件?

My question: Is it possible to set a Prefix on Karate with the standalone jar to be able to easily read any file from other directories ?

推荐答案

可以尝试使用file:前缀,而不是classpath:前缀,它将支持来自当前工作目录的绝对或相对路径.

Can you try the file: prefix, instead of classpath: it will support absolute or even relative paths from current working directory.

版本0.8.0在文件路径处理方面存在一些错误,尤其是在Windows上.因此,如果遇到问题,请尝试使用0.9.0.RC4-但无论如何都要提供反馈.

Version 0.8.0 had some bugs with file path handling especially on Windows. So try 0.9.0.RC4 if you get stuck - but do provide feedback on it if possible anyways.

这篇关于[karate] [standalone]错误:找不到或读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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