spring shell 方法参数列表<>
spring shell method parameter List<>
如何使用带有 List<> 参数的 spring shell 方法?
是否可以在 Spring_Shell 中使用 List<> 作为方法参数?
如下:
public void test(
@CliOption(key = "name", help ="") final String name,
@CliOption(key = "activities",help ="") final List<String> activitiy){//....... something to do}
你当然可以做到,但是由你来提供 Converter for it. It would be much better to use a String[]
(and optionally convert it to a List<String>
as your first instruction in your method body if you really need to), as arrays are supported out of the box(并支持转换和完成,这在 List
中是不可能的,因为类型擦除)
如何使用带有 List<> 参数的 spring shell 方法?
是否可以在 Spring_Shell 中使用 List<> 作为方法参数?
如下:
public void test(
@CliOption(key = "name", help ="") final String name,
@CliOption(key = "activities",help ="") final List<String> activitiy){//....... something to do}
你当然可以做到,但是由你来提供 Converter for it. It would be much better to use a String[]
(and optionally convert it to a List<String>
as your first instruction in your method body if you really need to), as arrays are supported out of the box(并支持转换和完成,这在 List
中是不可能的,因为类型擦除)