IntelliJ 中的 CLI-Spring Shell
CLI-Spring Shell in IntelliJ
我正在使用 IntelliJ 编写 CLI Spring shell 代码。
我运行它并给出了一些参数。但是当我输入 insert 并按下 enter 时,控制台不接受它并且看起来好像什么也没发生!
我的代码:
@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。如需帮助,请按或键入 "hint",然后按 ENTER。
spring-shell>
Spring Shell 使用 Jline。 您必须在 Intellij 中编辑 运行 配置并将 vm 选项参数添加为关注:
Unix 机器:
-Djline.terminal=org.springframework.shell.core.IdeTerminal
在 Windows 台机器上:
-Djline.WindowsTerminal.directConsole=false -Djline.terminal=jline.UnsupportedTerminal
我正在使用 IntelliJ 编写 CLI Spring shell 代码。 我运行它并给出了一些参数。但是当我输入 insert 并按下 enter 时,控制台不接受它并且看起来好像什么也没发生!
我的代码:
@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。如需帮助,请按或键入 "hint",然后按 ENTER。
spring-shell>
Spring Shell 使用 Jline。 您必须在 Intellij 中编辑 运行 配置并将 vm 选项参数添加为关注:
Unix 机器:
-Djline.terminal=org.springframework.shell.core.IdeTerminal
在 Windows 台机器上:
-Djline.WindowsTerminal.directConsole=false -Djline.terminal=jline.UnsupportedTerminal