spring boot 个性化设置 (一) 定制个性banner

spring boot 个性化设置 (一) 定制个性banner

spring boot 默认启动时的banner是这样的,太丑了 我们来私人定制下…

Imgur

1. 修改方法

step1. 在 /src/main/resources 目录下 新建banner.txt,

step2. 复制下方网站生成内容到banner.txt中,启动项目即可看到效果

img

2. 几个常用的字符生成网站

a.http://patorjk.com/software/taag 这个是比较常用的,可以根据输入的字符生成字符

imgurl

imgurl

b.https://www.degraeve.com/img2txt.php 可根据在线图片生成字符

imgurl

3. 改变banner颜色

banner.txt 中加上:${AnsiColor.BRIGHT_GREEN},AnsiColor 是Spring boot 提供的一个枚举类,用于控制banner的颜色

banner

4. 增加项目信息

除了美化功能,我们还可以给banner中增加一些项目信息

字符串 说明
${application.version} MANIFEST.MF文件中的版本号
${application.formatted-version} 上面的的版本号前面加v后上括号
${spring-boot.version} springboot的版本号
${spring-boot.formatted-version} springboot的版本号

效果如下:

banner

5. 禁用banner

public static void main(String[] args) {
        SpringApplication app = new SpringApplication(myApplication.class);
        app.setBannerMode(Banner.Mode.OFF);
        app.run(args);
    }

猜你喜欢

转载自blog.csdn.net/bdqx_007/article/details/83000046