IntelliJ中的CLI-Spring Shell

我正在使用IntelliJ中的CLI Spring shell代码。 我运行它并给出一些参数。 但是当我输入insert并按回车时,控制台不接受它,看起来好像什么也没发生!

我的代码:

@Component public class HelloWorldCommands implements CommandMarker { @CliCommand(value = "insert", help = "insert data to ParsEMS DB") public void insert() { try { Class.forName("org.postgresql.Driver"); Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/ParsEMS", "xxxxxx", "xxxxxxx"); Statement st = con.createStatement(); st.executeUpdate("INSERT INTO node (name, destination) VALUES ('b', 200)"); } catch (Exception e) { e.printStackTrace(); } System.out.println("insert to ParsEMS DB"); } } public class Main { public static void main(String[] args) throws Exception { Bootstrap.main(args); } } 

我运行时看到下面的结果;

1.1.0.RELEASE

欢迎来到Spring Shell。 如需帮助,请按或键入“提示”,然后按ENTER键。

弹簧壳>

Spring Shell使用Jline。 您必须编辑Intellij中的运行配置并添加vm选项参数,如下所示:

Unix机器:

 -Djline.terminal=org.springframework.shell.core.IdeTerminal 

在Windows机器上:

 -Djline.WindowsTerminal.directConsole=false -Djline.terminal=jline.UnsupportedTerminal