skip to Main Content

I’have created simple SpringShell app (java 21 and maven) using spring initializr and created class HelloCommand.java.
While running app in IntelliJ IDEA I’m occurring a warning Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information). If I build a .jar file and try to run in in windows 11 terminal problem still occur. From the other hand in WSL Ubuntu it doesn’t show an error, but interactive mode is still not working.

This is my Main class

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.shell.standard.ShellComponent;

@SpringBootApplication
public class demoApplication {

    public static void main(String[] args) {
        SpringApplication.run(demoApplication.class, args);
    }

And this is HelloCommand.java class

package com.example.demo.commands;

import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;

@ShellComponent
public class HelloCommand {

    @ShellMethod(key = "hello", value = "I will say hello")
    public String hello(){
        return "Hello world!";
    }
}

If I run app in non interactive mod with java -jar demo-0.0.1-SNAPSHOT.jar hello message is printed correctly

I have tried adding dependency

<dependency>
            <groupId>org.fusesource.jansi</groupId>
            <artifactId>jansi</artifactId>
            <version>2.4.0</version>
        </dependency>

to handle ansii escape keys, but it didnt help

2

Answers


  1. The official documentation doesn’t include this.
    Add this property

    spring.shell.interactive.enabled=true
    
    Login or Signup to reply.
  2. For me only after adding both configurations resolved the problem:

    spring.shell.interactive.enabled=true
    spring.shell.script.enabled=true
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search