此版本仍在开发中,尚未被认为是稳定版。请使用最新稳定版 Spring Shell 4.0.1spring-doc.cadn.net.cn

写作输出

当需要将内容写入控制台时,您可以始终使用JDK的System.out,这会直接进入JDK自己的流中。推荐的方式是从命令上下文中获取PrintWriter并用于写入。spring-doc.cadn.net.cn

@Command
public void example(CommandContext ctx) {
	ctx.outputWriter().println("hi");
	ctx.outputWriter().flush();
}