我正在尝试构建一个 Spring Shell 应用程序。我能够成功运行我的应用程序,但它立即退出@启动并且不等待用户输入。它似乎没有保留在 JLineShell promptLoop 方法中。
我正在构建一个带有 mainClassName =“org.springframework.shell.Bootstrap”的 jar。
我的 spring-shell-plugin.xml 如下:
<?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>
我的主要课程:
public class Main {
public static void main(String[] args) throws IOException{
Bootstrap.main(args);
}
}
我的命令类:
@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;
}
}