springboot 定制啟動圖案


Spring Boot在啟動的時候會顯示一個默認的Spring的圖案,對應的類為SpringBootBanner

圖案輸出有以下幾種模式,默認是CONSOLE的,即只打印到控制台,也可以輸出到日志文件

enum Mode {
   /**
    * Disable printing of the banner.
    */
   OFF,
   /**
    * Print the banner to System.out.
    */
   CONSOLE,
   /**
    * Print the banner to the log file.
    */
   LOG
}

關閉圖案

@SpringBootApplication
public class Application {
   public static void main(String[] args) {
       new SpringApplicationBuilder(Application.class).bannerMode(Banner.Mode.OFF)
               .run(args);
   }
}

定制圖案:在classpath目錄下創建banner.txt即可,把圖案放入該文件就行,這是Spring Boot默認的圖案位置,Spring Boot會自動加載該文件顯示圖案

生成圖案的網站:http://patorjk.com

也可以通過application配置文件來定制圖案

# 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)

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM