是一种在执行过程中捕获用户输入的方法@ShellMethod
。基本上停止执行请求用户输入的方法并在捕获后继续执行。
问问题
1053 次
2 回答
2
这里有可能的解决方案:https ://stackoverflow.com/a/50954716 ,由ZachOfAllTrades撰写
它仅在您的应用程序基于 SpringBoot 时才有效,因此您可以访问LineReader
由 SpringBoot 配置的对象。
@Autowired
LineReader reader;
public String ask(String question) {
return this.reader.readLine("\n" + question + " > ");
}
@ShellMethod(key = { "setService", "select" }, value = "Choose a Speech to Text Service")
public void setService() {
boolean success = false;
do {
String question = "Please select a service.";
// Get Input
String input = this.ask(question);
// Input handling
/*
* do something with input variable
*/
success = true;
}
} while (!success);
}
不过我自己没试过。
于 2018-11-13T07:02:06.920 回答
0
您应该能够直接与之交互,System.in
尽管它并不是 Spring Shell 的真正意义所在:命令应该是自包含的。
于 2018-01-05T12:42:28.843 回答