在运行时更改 spring shell 中的提示

Change the prompt in spring shell at runtime

是否可以更改 spring shell 应用程序中的提示?默认情况下,提示似乎是:

shell:>

是否可以在运行时更改此文本?

谢谢

你可以定义一个PromptProvider,见文档:https://docs.spring.io/spring-shell/docs/current-SNAPSHOT/reference/htmlsingle/#_promptprovider

谢谢您的回答!我忽略了这个功能。我创建了这个 class,将其放入我的 configuration-package 中,它对我很有用:

package de.myapp.spring.configuration;

@Configuration
@ComponentScan("de.myapp.spring.shell")
public class ShellApplicationConfiguration implements PromptProvider {

    @Override
    public final AttributedString getPrompt() {

        return new AttributedString("myapp:>");

    }

}