Spring Boot如何定制启动图案呢?
下文笔者讲述SpringBoot中定制启动图案的方法及示例分享,如下所示
SpringBoot常见启动图案
Spring Boot在启动的时候会显示一个默认的Spring的图案,对应的类为SpringBootBanner。 . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.6.RELEASE)
图案输出的模式--默认类型为CONSOLE
enum Mode { /** * Disable printing of the banner. */ OFF, /** * Print the banner to System.out. */ CONSOLE, /** * Print the banner to the log file. */ LOG }
SpringBoot关闭启动图案的实现思路
@SpringBootApplication public class Application { public static void main(String[] args) { new SpringApplicationBuilder(Application.class).bannerMode(Banner.Mode.OFF) .run(args); } }
SpringBoot定制图案的示例
只需在classpath目录下创建banner.txt即可 将图案放入该文件就行 此位置是Spring Boot默认图案位置 Spring Boot会自动加载该文件显示图案 生成图片,可使用以下网址 http://patorjk.com
使用自定义图片---作为启动图案
# 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)
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。