You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Karate至1.4.0后Eclipse报错:找不到main类cucumber.api.cli.Main

解决Karate 1.4.0升级后Eclipse运行Feature文件报错问题

问题原因

Karate 1.4.0版本移除了对Cucumber旧版API(cucumber.api.cli.Main)的依赖,而Eclipse中原有运行配置仍在调用该类,因此触发ClassNotFoundException。

解决方案

1. 更新Eclipse运行配置

  • 右键目标feature文件,选择Run As > Run Configurations...
  • 在弹出窗口中找到对应运行配置,切换到Main标签页
  • 将Main class从cucumber.api.cli.Main替换为com.intuit.karate.cli.Main
  • 点击Apply保存配置后重新运行

2. 校验项目依赖

确保项目依赖只保留Karate核心依赖,移除冗余的Cucumber旧版依赖。以Maven为例,正确的核心依赖配置如下:

<dependency>
    <groupId>com.intuit.karate</groupId>
    <artifactId>karate-core</artifactId>
    <version>1.4.0</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>com.intuit.karate</groupId>
    <artifactId>karate-junit5</artifactId>
    <version>1.4.0</version>
    <scope>test</scope>
</dependency>

3. 升级Karate Eclipse插件

若使用了Karate的Eclipse插件,需升级至与1.4.0版本兼容的最新版本,插件会自动适配新的运行入口类。

内容的提问来源于stack exchange,提问作者cyrilgeorge153

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 00:20:53