Reputation: 101
I am attempting to build a Spring Shell application. I am able to run my application successfully but it exits immediately @ startup & does not await user input. It seems to not remain in the JLineShell promptLoop method.
I am building a jar with a mainClassName = "org.springframework.shell.Bootstrap".
My spring-shell-plugin.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="com.zailab" />
</beans>
My Main class:
public class Main {
public static void main(String[] args) throws IOException{
Bootstrap.main(args);
}
}
My Command class:
@Component
public class BuildCommand implements CommandMarker {
@CliAvailabilityIndicator({"echo"})
public boolean isCommandAvailable() {
return true;
}
@CliCommand(value = "echo", help = "Echo a message")
public String echo(
@CliOption(key = { "", "msg" }, mandatory = true, help= "The message to echo") String msg) {
return msg;
}
}
Upvotes: 1
Views: 3123
Reputation: 4877
You can also start your app in IDE without returning immediately.
You have to put the following JVM parameters to your run configuration:
for *nix machines:
-Djline.terminal=org.springframework.shell.core.IdeTerminal
for Windows machines:
-Djline.WindowsTerminal.directConsole=false
-Djline.terminal=jline.UnsupportedTerminal
Upvotes: 6
Reputation: 101
I've figured out what the issue was. Do not attempt to start the shell from within an IDE(STS to be exact). It seems an EOF is returned immediately when running the app from within the IDE, works perfectly via command line.
Thanks
Upvotes: 0