IntelliJ中的CLI-Spring Shell [英] CLI-Spring Shell in IntelliJ

查看:366
本文介绍了IntelliJ中的CLI-Spring Shell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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!

我的代码:

@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

1.1.0.RELEASE

欢迎使用Spring Shell。如需帮助,请按或键入提示,然后按ENTER键。

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

spring-shell>

spring-shell>

推荐答案

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

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

Unix机器:

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

在Windows机器上:

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

这篇关于IntelliJ中的CLI-Spring Shell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆