我正在尝试构建一个Spring应用程序。我能够成功地运行我的应用程序,但它会立即退出@ startup &不等待用户输入。它似乎不在JLineShell promptLoop方法中。
我正在用mainClassName = "org.springframework.shell.Bootstrap“构建一个jar。
我的spring 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-29 15:09:46
我已经弄清楚问题出在哪里了。不要试图从IDE中启动shell (确切地说,是STS)。在IDE中运行应用程序时,似乎会立即返回EOF,通过命令行可以很好地工作。
谢谢
发布于 2014-11-29 15:56:56
您也可以在IDE中启动应用程序,而无需立即返回。
您必须将以下JVM参数放到运行配置中:
用于*nix机器:
-Djline.terminal=org.springframework.shell.core.IdeTerminal
对于Windows机器:
-Djline.WindowsTerminal.directConsole=false
-Djline.terminal=jline.UnsupportedTerminal
https://stackoverflow.com/questions/25991910
复制相似问题