天天看點

Spring Boot 定制banner緒論正文結果

緒論

SpringBoot項目在啟動的時候會列印一個banner,怎樣定制一個呢?如果不需要,怎麼關閉呢?

正文

下面這幾個網站可以線上生成:

  1. http://patorjk.com/software/taag
  2. http://www.network-science.de/ascii/
  3. http://www.kammerl.de/ascii/AsciiSignature.php
88b           d88               ad888888b,
                       888b         d888              d8"     "88
                       88`8b       d8'88                      a8P
                       88 `8b     d8' 88  8b,dPPYba,       aad8"  8b       d8
                       88  `8b   d8'  88  88P'   "Y8       ""Y8,  `8b     d8'
                       88   `8b d8'   88  88                  "8b  `8b   d8'
                       88    `888'    88  88     888  Y8,     a88   `8b,d8'
                       88     `8'     88  88     888   "Y888888P'     Y88'
                                                                      d8'
                                                                     d8'
           

在resources目錄下建立一個banner.txt檔案,把網頁中生成好的内容粘貼進去,重新啟動項目就行了。

Spring Boot 定制banner緒論正文結果

如果想關閉,在項目啟動時候不展示該内容怎麼辦?通過Banner.Mode.OFF關閉掉就可以了。

import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;

@SpringBootApplication
public class DemoJarApplication {

	public static void main(String[] args) {
//		SpringApplication.run(DemoJarApplication.class, args);

		SpringApplicationBuilder builder = new SpringApplicationBuilder(DemoJarApplication.class);
		builder.bannerMode(Banner.Mode.OFF).run(args);
	}

}
           

結果

(若有什麼錯誤,請留言指正,3Q)