SpringBoot啟動時的Banner設置


Spring Boot程序啟動的時候輸出的由字符組成的Spring符號並不陌生。這個是Spring Boot為自己設計的Banner:

 

1. 第一種方式:修改的時候,進行設置,在Application的main方法中:

SpringApplication application = new SpringApplication(App.class);
/*
* Banner.Mode.OFF:關閉;
* Banner.Mode.CONSOLE:控制台輸出,默認方式;
* Banner.Mode.LOG:日志輸出方式;
/
application.setBannerMode(Banner.Mode.OFF*);
application.run(args);

2. 第二種方式:修改banner.txt配置文件

在src/main/resouces下新建banner.txt,在文件中加入:

#這個是MANIFEST.MF文件中的版本號 
${application.version}              
 
#這個是上面的的版本號前面加v后上括號 
${application.formatted-version}
 
#這個是springboot的版本號 
${spring-boot.version}             
 
#這個是springboot的版本號 
${spring-boot.formatted-version}

3. 第三種方式:重寫接口Banner實現

SpringBoot提供了一個接口org.springframework.boot.Banner,他的實例可以被傳給SpringApplication的setBanner(banner)方法。如果你閑得不行非要着重美化這個命令行輸出的話,可以重寫Banner接口的printBanner方法。

4. 第四種方式:在application.properties進行配置

在application.proerpties進行banner的顯示和關閉:

#是否顯示banner,可選值[true|false]
spring.main.show-banner=false

提供圖案生成網站:  http://www.bootschool.net/ascii

http://patorjk.com/software/taag/#p=display&h=0&v=0&f=Big&t=baidu

 

 

 

甚至於你還可以玩得更high點,制作出圖片的banner.txt來,隨便去網上找了個小姐姐圖片,試了一下:
網址路徑:https://www.degraeve.com/img2txt.php

 


免責聲明!

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



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