我正在嘗試構建Spring Shell應用程序。 我能夠成功運行我的應用程序,但它立即退出@啓動&不會等待用戶輸入。它似乎不保留在JLineShell promptLoop方法中。Spring Shell - 命令提示立即退出,不等待用戶輸入
我正在用mainClassName =「org.springframework.shell.Bootstrap」構建一個jar。
我的春天殼的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;
}
}
請張貼一些代碼/配置。 – 2014-09-23 09:49:48
增加的代碼&config – 2014-09-23 09:57:27
可能不是根本原因,但爲什麼有一個主類不做任何事情,而是委託給Bootsrap類?另外,你appContext xml文件是否正確放置並且在/META-INF/spring/spring-shell-plugin.xml下可見。 – ebottard 2014-09-23 16:21:43