CLI-Spring Shell in IntelliJ

霸气de小男生 提交于 2019-11-29 13:27:38

问题


I am working on a CLI Spring shell code in IntelliJ. I run it and give some parameters. But when I type insert and press enter, console doesn't take it and it appears as if nothing happened!

My code:

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

I see below result when I run it;

1.1.0.RELEASE

Welcome to Spring Shell. For assistance press or type "hint" then hit ENTER.

spring-shell>


回答1:


Spring Shell uses Jline. You will have to edit the run configuration inside your Intellij and add the vm options arguments as follow:

Unix machines:

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

On Windows machines:

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


来源:https://stackoverflow.com/questions/30450346/cli-spring-shell-in-intellij

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!