0

I have a problem while running spring boot spring shell application. I have implemented commandlinerunner but its never called during application startup.

@Component
public class ParamReader implements CommandLineRunner {

    @Override
    public void run(String... args) throws Exception {
        if(args.length>0) {
            System.out.println(Arrays.asList(args).stream().collect(Collectors.joining(", ")));
        }
    }
}

when i run exit command from shell, its calling the run method and then program terminates. I tried implementing commandlinerunner on Spring application main class but the result is same.

Gus
  • 3,534
  • 1
  • 30
  • 39

1 Answers1

1

Spring shell uses an ApplicationRunner with @Order annotation and precedence 0. You could try the following:

@Order(-1)
@Component
public class ParamReader implements CommandLineRunner {

    @Override
    public void run(String... args) throws Exception {
        if(args.length>0) {
            System.out.println(Arrays.asList(args).stream().collect(Collectors.joining(", ")));
        }
    }
}
xKobalt
  • 1,498
  • 2
  • 13
  • 19
Zettaka
  • 11
  • 1