空手道参考:未定义的软件包

发布于 2025-02-03 15:08:27 字数 741 浏览 4 评论 0原文

我正在使用空手道功能文件中的Java代码,引用GitHub Demo:

Background:
* url demoBaseUrl
* def JavaDemo = Java.type('com.intuit.karate.demo.util.JavaDemo')

我注意到该功能文件位于SRC/test/java中,该文件在pom.xml中定义为classPath。同时,UTIL类位于SRC/Main/Java中。

在我的项目中,我使用类似的结构

”在此处输入图像描述“

以下代码在功能文件中,带有类参考:

    * def XMLValidator = Java.type(base.utility.XMLValidator)
    * def validator = new XMLValidator()

但是我在下面有一个例外:

org.graalvm.polyglot.PolyglotException: ReferenceError: "base" is not defined

这是类问题吗?

I'm using java codes in karate feature file, refering github demo:

Background:
* url demoBaseUrl
* def JavaDemo = Java.type('com.intuit.karate.demo.util.JavaDemo')

I noticed that the feature file is in src/test/java, which defined as classpath in pom.xml. Meanwhile the util class is in src/main/java.

In my project I use similar structure

enter image description here

Following code is in the feature file with Class Reference:

    * def XMLValidator = Java.type(base.utility.XMLValidator)
    * def validator = new XMLValidator()

But I got an exception below:

org.graalvm.polyglot.PolyglotException: ReferenceError: "base" is not defined

Is it a classpath problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抠脚大汉 2025-02-10 15:08:27

您不是缺少引号(对于java.type()的字符串参数

* def XMLValidator = Java.type('base.utility.XMLValidator')

Aren't you missing the quotes (for a string argument to Java.type()

* def XMLValidator = Java.type('base.utility.XMLValidator')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文