【问题标题】:Picocli - "Missing required Parameters" even when passed parametersPicocli - 即使传递了参数,“缺少必需的参数”
【发布时间】:2022-01-20 17:33:35
【问题描述】:
@Parameters(paramLabel = "AMOUNT", description = "the depth to scrape for")
private int amount;

@Parameters(paramLabel = "ENTRY_POINT", description = "the entry point for the scrape")
private String entryPoint;

我的 Main 类中有这些参数。 当我使用ClassName 5 https://www.baeldung.com/ 运行程序时,我得到了

Missing required parameters: 'AMOUNT', 'ENTRY_POINT'
Usage: <main class> AMOUNT ENTRY_POINT
      AMOUNT        the depth to scrape for
      ENTRY_POINT   the entry point for the scrape

有人知道为什么会这样吗?

如果需要,我可以提供更多代码。

【问题讨论】:

  • 这是 minimal reproducible example 有用的地方。基本上没有人能回答你的问题,除非你基本上猜测你做了什么......而如果你写了一个最小的例子,你很可能在问问题之前就发现了问题。

标签: java command-line-interface picocli


【解决方案1】:

已解决;我没有在我的主要方法中从命令行传递参数...

很愚蠢的哈哈。

以前,不工作

public static void main(String[] args) {
    var cmd = new CommandLine(new Scraper());
    cmd.execute();
}

之后,工作

public static void main(String[] args) {
    var cmd = new CommandLine(new Scraper());
    cmd.execute(args);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-05
    • 1970-01-01
    • 2018-10-28
    • 2018-12-01
    • 2016-06-29
    • 2018-06-20
    • 2020-09-27
    相关资源
    最近更新 更多