啟動springboot應(yīng)用的時候,會打印出默認的banner,

如何關(guān)閉自定義的banner?
package com.zhihao.miao.springboot;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(Application.class);
//關(guān)閉默認的banner,默認的值為Banner.Mode.CONSOLE
springApplication.setBannerMode(Banner.Mode.OFF);
springApplication.run(args);
}
}
如何自定義banner?
只需要在classpath下面定義一個banner.txt文件,即可定義自定義banner。
我在resource下定義的banner.txt:
十步殺一人,千里不留行。

圖片.png
當然也可以自己指定banner的路徑和編碼(默認編碼是UTF-8),在application.properties
我在classpath下面定義一個文件夾bannner,在bannner文件夾下定義mybannner.txt文件,

application.properties中的配置:
banner.location=classpath:banner/mybanner.txt
banner.charset=UTF-8
打印結(jié)果:

圖片.png
圖片banner
springboot支持圖片的banner,圖片格式支持jpg,png,gif,banner.image.location 配置項用來指定圖片banner的文件路徑。
在classpath下增加banner.jpg圖片文件,然后在配置文件中指定圖片banner的目錄:
banner.image.location=banner.jpg
打印結(jié)果,顯示banner。