SpringBoot自定义Banner
@FunctionalInterface
public interface Banner {
void printBanner(Environment environment, Class sourceClass, PrintStream out);
public static enum Mode {
//不显示banner
OFF,
//仅在控制台显示
CONSOLE,
//在日志中也显示
LOG;
private Mode() {
}
}
}
public class MyBanner implements Banner {
@Override
public void printBanner(Environment environment, Class sourceClass, PrintStream out) {
out.println("this is my banner!!!!!");
out.println(AnsiOutput.toString(new Object[]{AnsiColor.GREEN, " :: miBanner :: ", AnsiColor.DEFAULT, "\t\t\t", AnsiStyle.FAINT, "1.0"}));
out.println();
}
}
public static void main(String[] args) throws InterruptedException {
SpringApplication builder=new SpringApplicationBuilder(Demo1Application.class).banner(new MyBanner()).bannerMode(Banner.Mode.CONSOLE).initializers(new MyTianApplicationInitlize()).build();
builder.run(args);
}
评论