Annotation
p. “@Command annotation when used on a method marks it as a candidate for command registration”
p. “@Command annotation can be placed on a class which either defines defaults or shared settings for @Command methods defined in a same class.”
p. “Using a @Command will not automatically register command targets, instead it is required to use @EnableCommand and/or @CommandScan annotations.”
Where should we put
@EnableCommandor@CommandScanannotations?
- Both can be located at
@Configurationclass, and mostly at@SpringBootApplication.@EnableCommandis used with a specified class that’s annotated with@Command.@CommandScanis used with abasePackages/basePackageClasses, andvalueso it’s useful for managing many commands.
p. “You can define target classes using @EnableCommand. It will get picked from all Configuration classes.”
If you specify the A.class in
@EnableCommand, It finds the class A's bean with@Commandannotation from all@Configurationclasses.
p. “Define @CommandScan in Spring Boot App class on a top level and it will automatically scan all command targets from all packages and classes under App.”