Spring boot Create a Custom Banner Example

摘要: You can change the mission critical banner that is printed on start up with your own custom banner. You have the option to add your own custom banner.txt text file by setting the banner.location to the location of such a file. The default charset is UTF-8. In addition you can also add a banner.gif, banner.jpg or banner.png image file or set a banner.image.location property. Images will be converted into an ASCII art representation and printed above any text banner. In this tutorial we demonstrate how to create a custom banner using spring boot. We Generated an ascii art and place it in a file called banner.txt and place it in the directory src/main/resources.

You can change the mission critical banner that is printed on start up with your own custom banner. You have the option to add your own custom banner.txt text file by setting the banner.location to the location of such a file. The default charset is UTF-8. In addition you can also add a banner.gif, banner.jpg or banner.png image file or set a banner.image.location property. Images will be converted into an ASCII art representation and printed above any text banner. In this tutorial we demonstrate how to create a custom banner using spring boot. We Generated an ascii art and place it in a file called banner.txt and place it in the directory src/main/resources.

Spring Boot – Custom Banner

In this example we opted for a custom banner.txt file, which we placed in the src/main/resources folder. Spring boot’ll automatically use this file.

${Ansi.GREEN}                                                      _    __                       _
${Ansi.GREEN}    /\/\   ___ _ __ ___   ___  _ __ _   _ _ __   ___ | |_ / _| ___  _   _ _ __   __| |  ___ ___  _ __ ___
${Ansi.GREEN}   /    \ / _ \ '_ ` _ \ / _ \| '__| | | | '_ \ / _ \| __| |_ / _ \| | | | '_ \ / _` | / __/ _ \| '_ ` _ \
${Ansi.GREEN}  / /\/\ \  __/ | | | | | (_) | |  | |_| | | | | (_) | |_|  _| (_) | |_| | | | | (_| || (_| (_) | | | | | |
${Ansi.GREEN}  \/    \/\___|_| |_| |_|\___/|_|   \__, |_| |_|\___/ \__|_|  \___/ \__,_|_| |_|\__,_(_)___\___/|_| |_| |_|
${Ansi.GREEN}                                    |___/
${Ansi.RED} :: Spring Boot${spring-boot.formatted-version} :: ${Ansi.DEFAULT}

Tweaking the banner

You can further tweak the banner by adding the following properties to your application.properties file.

# BANNER
banner.charset=UTF-8 # Banner file encoding.
banner.location=classpath:banner.txt # Banner file location.
banner.image.location=classpath:banner.gif # Banner image file location (jpg/png can also be used).
banner.image.width= # Width of the banner image in chars (default 76)
banner.image.height= # Height of the banner image in chars (default based on image height)
banner.image.margin= # Left hand image margin in chars (default 2)
banner.image.invert= # If images should be inverted for dark terminal themes (default false)

Bootstrap Application

package com.memorynotfound.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

}

Generated Output

The previous configuration prints the following output to the console.

Download

上一篇: Spring Boot Create Executable using Maven with Parent Pom
下一篇: Spring Security + Spring LDAP Authentication Configuration Example
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号