SpringBoot(四):banner的控制

banner在springboot中是一个支持可配(banner的样式,banner的颜色,banner的内容)、是否显示。

1)banner显示内容配置:

默认springboot如果在src/resources下包含这样的一个banner信息,则会使用该banner.txt内容替换spring boot默认的banner信息:

${AnsiColor.BRIGHT_YELLOW}
                   ${AnsiColor.BRIGHT_RED}_ooOoo_${AnsiColor.BRIGHT_YELLOW}
                  ${AnsiColor.BRIGHT_RED}o8888888o${AnsiColor.BRIGHT_YELLOW}
                  ${AnsiColor.BRIGHT_RED}88${AnsiColor.BRIGHT_YELLOW}" . "${AnsiColor.BRIGHT_RED}88${AnsiColor.BRIGHT_YELLOW}
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG

备注:

1)其中banner.txt内容的中第一行信息,用来配置banner.txt的文字颜色;

2)其中被颜色样式包含的banner内容是对banner个别信息颜色的修改。

2)banner是否显示配置方式:

方式1)通过src/resources/applicatioin.properties配置:

# 可选值:console.off.log
spring.main.banner-mode=off

方式2)通过启动入口函数配置:

package app;

import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;

import java.util.Arrays;

@ComponentScan("com.dx.controller")
@EnableAutoConfiguration
public class App {
    public static void main(String[] args) {
        System.out.println(Arrays.toString(args));
        // 启动方式一:
//        SpringApplication.run(App.class, args);

        // 启动方式二:
//        SpringApplication springApplication = new SpringApplication(App.class);
//        springApplication.setBannerMode(Banner.Mode.OFF);
//        springApplication.run(args);

        // 启动方式三:
        new SpringApplicationBuilder(App.class)
                .bannerMode(Banner.Mode.OFF)
                .build()
                .run(args);
    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值