【问题标题】:Spring shell command line application returning null from a shell methodSpring shell 命令行应用程序从 shell 方法返回 null
【发布时间】:2022-12-21 17:28:14
【问题描述】:

我有一个简单的 CLI 应用程序,可以从官方文档 here 中打印出你的名字。

@ShellComponent
public class Cli {

 @ShellMethod("Say my name")
 public String hi(@ShellOption(value = {"name"}) String arg1){
    return "Hi " + arg1 + "!!";
 }
}

当我运行hi --name Chandler时,我得到Hi null!!我做错了什么?

【问题讨论】:

    标签: java spring spring-boot command-line-interface spring-shell


    【解决方案1】:

    您能确保您使用的 spring-shell 版本与您使用的文档匹配吗?

    使用上面的代码,Spring Boot 3.0.0 和 Spring Shell 3.0.0-M3 按预期工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-10
      • 2018-03-10
      • 2019-03-10
      • 2012-12-22
      • 2014-03-06
      • 2011-07-18
      • 2012-05-28
      相关资源
      最近更新 更多