I have my class:
package com.ejemplo.prueba;
import org.springframework.shell.standard.ShellComponent
import org.springframework.shell.standard.ShellMethod
@ShellComponent
class MyShellCommands {
@ShellMethod("Este es un comando de ejemplo")
def myCommand() {
return "¡Hola desde Groovy!"
}
}
But when I execute the shell, it's fail:
shell:>myCommand No command found for 'myCommand'
My depencies maven in pom are:
Springoot 3.1.4 and Spring shell 3.1.3 and
The execution in shell should show:
¡Hola desde Groovy!
As can be seen in documentation if you don't specify the
keyattribute of@ShellMethodannotation, then per default you camelCasemyCommandgets converted to kebap case (my-command).@ShellMethod(key = "myCommand", value = "Este es un comando de ejemplo")my-commandfrom the commandline.Try also using
helpto see the list of available commands