此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Shell 3.3.3! |
注解
@Command
注解时,将其标记为命令注册的候选项。
在下面的示例中,命令example
已定义。
class Example {
@Command(command = "example")
public String example() {
return "Hello";
}
}
@Command
注解可以放置在定义 defaults 或 shared settings 的类上
为@Command
方法。在下面的示例中,命令parent example
是
定义。
@Command(command = "parent")
class Example {
@Command(command = "example")
public String example() {
return "Hello";
}
}
使用@Command
不会自动注册命令目标,而是需要使用@EnableCommand
和/或@CommandScan
附注。这个模型与其他部分很相似
Spring 伞,为用户提供更好的灵活性,使其具有包容性而不是排他性
对于命令目标。
您可以使用@EnableCommand
.它将从所有 Configuration 类中选取。
@EnableCommand(Example.class)
class App {
}
您可以使用@CommandScan
.它将从所有 Configuration 类中选取。
定义@CommandScan 在 Spring Boot 中App 类,它将自动
扫描 下所有包和类中的所有命令目标App . |
@CommandScan
class App {
}