我在运行 Spring Boot Spring Shell 应用程序时遇到问题。我已经实现了 commandlinerunner,但它从未在应用程序启动期间调用过。
@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(", ")));
}
}
}
当我从 shell 运行 exit 命令时,它调用 run 方法,然后程序终止。我尝试在 Spring 应用程序主类上实现 commandlinerunner,但结果是一样的。