编程
在程序化模型中,指挥注册可以定义为@Bean而且它会自动注册。
@Bean
CommandRegistration commandRegistration() {
return CommandRegistration.builder()
.command("mycommand")
.build();
}
如果你所有的命令都有共同点,比如 创建一个 CommandRegistration.BuilderSupplier,可以 自动接线。该提供商的默认实现会返回 是新建的,所以你不用担心它的内部状态。
| 命令自动编程注册 添加帮助选项中提到的帮助选项。 |
如果定义了该提供商类型的豆子,则自动配置 我会退一步,给你重新定义默认功能的选项。
@Bean
CommandRegistration commandRegistration(CommandRegistration.BuilderSupplier builder) {
return builder.get()
.command("mycommand")
.build();
}
指令注册定制器豆子可以被定义为中心化的
请修改提供商提供的架构实例,如下所述:
@Bean
CommandRegistrationCustomizer commandRegistrationCustomizerExample() {
return builder -> {
// customize instance of CommandRegistration.Builder
};
}