Spring Boot 2.X 修改启动图标

Spring Boot 默认打印的 banner

在这里插入图片描述要想修改它,需要在 resources 目录下添加一个 banner.txt 文件

banner.txt 文件语法

${application.version} 				MANIFEST.MF文件中的版本号(目前无法获取到,应该是spring的一个BUG)
${application.formatted-version} 	上面的的版本号前面加v后上括号 
${spring-boot.version} 				springboot的版本号 
${spring-boot.formatted-version}	上面的的版本号前面加v后上括号  

spring-boot.version 是在 build.gralde 中定义的

buildscript {
	ext {
		springBootVersion = '2.1.1.RELEASE'
	}
}

AnsiColor 支持的颜色可以在官网查到 https://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/ansi/AnsiColor.html

  • BLACK
  • BLUE
  • BRIGHT_BLACK
  • BRIGHT_BLUE
  • BRIGHT_CYAN
  • BRIGHT_GREEN
  • BRIGHT_MAGENTA
  • BRIGHT_RED
  • BRIGHT_WHITE
  • BRIGHT_YELLOW
  • CYAN
  • DEFAULT
  • GREEN
  • MAGENTA
  • RED
  • WHITE
  • YELLOW

Spring Boot支持高亮输出(即 带颜色的输出),但默认是关闭的,需要在 application.properties 中添加如下内容开启:
spring.output.ansi.enabled=ALWAYS

如果想关闭 Banner 的打印,就修改 YourProjectApplication.java,来禁用输出 Banner

public static void main(String[] args) {
	//SpringApplication.run(DemoApplication.class, args);
	SpringApplication springApplication = new SpringApplication(DemoApplication.class);
	springApplication.setBannerMode(Banner.Mode.OFF);
	springApplication.run(args);
}

ASCII 字符画生成工具

banner.txt 实践

${AnsiColor.CYAN}
______                              
| ___ \                             
| |_/ / __ _ _ __  _ __   ___ _ __  
| ___ \/ _` | '_ \| '_ \ / _ \ '__| 
| |_/ / (_| | | | | | | |  __/ |    
\____/ \__,_|_| |_|_| |_|\___|_|    
${AnsiColor.MAGENTA}                                
 :: Spring Boot ::${application.version}        ${spring-boot.formatted-version}
${AnsiColor.BRIGHT_YELLOW} Application Version: ${application.version}${application.formatted-version}
${AnsiColor.BRIGHT_BLUE} Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}

在这里插入图片描述
网上找的一张佛陀的好运图。。。


//                         _oooOooo_                              //
//                        o888888888o                             //
//                        88"  .  "88                             //
//                        (|  ^_^  |)                             //
//                        O\   =   /O                             //
//                     ____/`-----'\____                          //
//                    .'  \\|     |//  `.                         //
//                   /  \\|||  :  |||//  \                        //
//                  /  _||||| -:- |||||-  \                       //
//                  |   | \\\  -  /// |   |                       //
//                  | \_|  ''\---/''  |   |                       //
//                  \  .-\__  `-`  ___/-. /                       //
//                ___`. .'  /--.--\  `. . ___                     //
//              ."" '<  `.___\_<|>_/___.'  >'"".                  //
//            | | :  `- \`.;`\ _ /`;.`/ - ` : | |                 //
//            \  \ `-.   \_ __\ /__ _/   .-` /  /                 //
//      ========`-.____`-.___\_____/___.-`____.-'========         //
//                           `=---='                              //
//      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        //
//            佛祖保佑       永不宕机     永无BUG                 //

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值