我正在尝试编写一个Spring shell应用程序并传递一些var参数。基本上我希望传递fetch FA-207542 FA-207984 FA-211258 FA-202298
此处的文档仍待定
@ShellMethod(value = "fetches all pic related data for processing")
fun fetch(vararg tickets: String) {
println("number of tickets is ${tickets.size}")
}
成果
shell:>fetch FA-207542 FA-207984 FA-211258 FA-202298
number of tickets is 1
我尝试使用StringArray
,但出现错误:
fun fetch(tickets: StringArray) {
println("number of tickets is ${tickets.size()}")
}
错误:
shell:>fetch FA-207542 FA-207984 FA-211258 FA-202298
Parameter specified as non-null is null: method FetchCommand.fetch, parameter tickets
Details of the error have been omitted. You can use the stacktrace command to print the full stacktrace.
1条答案
按热度按时间4ktjp1zp1#
使用java(sry),我可以实现以下功能:
然后:
使用以下产品可获得相同的结果:分别为
@ShellCommand(arity = -1)
和arity = Integer.MAX_VALUE
。#