I’ve run aground when trying to do the Spring Shell Tutorial. I
downloaded a basic application from Spring Intializr with the
following properties:
- Project : Gradle – Groovy
- Spring Boot: 3.3.0
- Group : test
- Artifact : demo
- Packaging : Jar
- Java : 17
I created it once for Java and once for Groovy.
I created a command file in both versions with identical contents:
- src/main/java/test/demo/SampleCommands.java
- src/main/groovy/test/demo/SampleCommands.groovy
<code>
package test.demo;
import org.springframework.shell.standard.*;
@ShellComponent
public class SampleCommands {
@ShellMethod(key = "hello-world")
public String helloWorld(
@ShellOption(defaultValue = "spring") String arg
) {
return "Hello world " + arg;
}
}
</code>
<code>
package test.demo;
import org.springframework.shell.standard.*;
@ShellComponent
public class SampleCommands {
@ShellMethod(key = "hello-world")
public String helloWorld(
@ShellOption(defaultValue = "spring") String arg
) {
return "Hello world " + arg;
}
}
</code>
package test.demo;
import org.springframework.shell.standard.*;
@ShellComponent
public class SampleCommands {
@ShellMethod(key = "hello-world")
public String helloWorld(
@ShellOption(defaultValue = "spring") String arg
) {
return "Hello world " + arg;
}
}
Both versions compile without trouble, and will list the hello-world
command when you run help
.
<code>AVAILABLE COMMANDS
Built-In Commands
help: Display help about available commands
history: Display or save the history of previously run commands
version: Show version info
script: Read and execute commands from a file.
Sample Commands
hello-world:
</code>
<code>AVAILABLE COMMANDS
Built-In Commands
help: Display help about available commands
history: Display or save the history of previously run commands
version: Show version info
script: Read and execute commands from a file.
Sample Commands
hello-world:
</code>
AVAILABLE COMMANDS
Built-In Commands
help: Display help about available commands
history: Display or save the history of previously run commands
version: Show version info
script: Read and execute commands from a file.
Sample Commands
hello-world:
The sample command works in the Java version.
<code>Hello world spring
</code>
<code>Hello world spring
</code>
Hello world spring
But it dies when you run the Groovy Version
<code>java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not found in class file either.
at org.springframework.shell.support.AbstractArgumentMethodArgumentResolver.updateNamedValueInfo(AbstractArgumentMethodArgumentResolver.java:154) ~[spring-shell-core-3.3.0.jar!/:3.3.0]
at org.springframework.shell.support.AbstractArgumentMethodArgumentResolver.getNamedValueInfo(AbstractArgumentMethodArgumentResolver.java:129) ~[spring-shell-core-3.3.0.jar!/:3.3.0]
...and much, much more....
</code>
<code>java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not found in class file either.
at org.springframework.shell.support.AbstractArgumentMethodArgumentResolver.updateNamedValueInfo(AbstractArgumentMethodArgumentResolver.java:154) ~[spring-shell-core-3.3.0.jar!/:3.3.0]
at org.springframework.shell.support.AbstractArgumentMethodArgumentResolver.getNamedValueInfo(AbstractArgumentMethodArgumentResolver.java:129) ~[spring-shell-core-3.3.0.jar!/:3.3.0]
...and much, much more....
</code>
java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not found in class file either.
at org.springframework.shell.support.AbstractArgumentMethodArgumentResolver.updateNamedValueInfo(AbstractArgumentMethodArgumentResolver.java:154) ~[spring-shell-core-3.3.0.jar!/:3.3.0]
at org.springframework.shell.support.AbstractArgumentMethodArgumentResolver.getNamedValueInfo(AbstractArgumentMethodArgumentResolver.java:129) ~[spring-shell-core-3.3.0.jar!/:3.3.0]
...and much, much more....
What am I doing wrong?