CLI- Spring Shell in IntelliJ

I am working on Spring CLI shell code in IntelliJ. I run it and set some parameters. But when I type insert and press enter, the console does not accept it, and it seems that nothing happened!

My code is:

@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); } } 

Below I see the result when I run it;

1.1.0.RELEASE

Welcome to Spring Shell. For help, press or enter β€œhint”, then press ENTER.

spring shell>

+6
source share
1 answer

Spring Shell uses Jline. You will need to edit the launch configuration inside your Intellij and add the vm options arguments as follows:

Unix machines:

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

On Windows computers:

 -Djline.WindowsTerminal.directConsole=false -Djline.terminal=jline.UnsupportedTerminal 
+12
source

Source: https://habr.com/ru/post/987899/


All Articles