开发者社区> java技术栈> 正文

Spring Boot定制启动图案

简介: 启动图案 Spring Boot在启动的时候会显示一个默认的Spring的图案,对应的类为SpringBootBanner。 . ____ _ __ _ _ /\\ / ___'_ __ _ ...
+关注继续查看

启动图案

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

}

关闭图案

@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

也可以使用图片,更详细的可以研究Banner接口及其子类,不过这也没什么卵用,有兴趣的可以深入了解下。

当然也支持通过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)

推荐:Spring Boot & Cloud 最强技术教程

扫描关注我们的微信公众号,干货每天更新。

image

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
玩“公主焊接”,顺便学习学习数据库关系映射与Spring Boot中MyBatis(SSM框架)的级联操作(bushi)
玩“公主焊接”,顺便学习学习数据库关系映射与Spring Boot中MyBatis(SSM框架)的级联操作(bushi)
82 0
Spring Boot AOP - 面向切面编程
Spring Boot AOP - 面向切面编程
116 0
Spring Boot中的校验-Validation的使用
Spring Boot中的校验-Validation的使用
68 0
Spring Boot发送邮件以及阿里云服务器无法发送邮件的问题解决
Spring Boot发送邮件以及阿里云服务器无法发送邮件的问题解决
112 0
Spring Boot实现文件上传
Spring Boot实现文件上传
108 0
Spring Boot资源文件问题总结(Spring Boot的静态资源访问,配置文件外置)
Spring Boot资源文件问题总结(Spring Boot的静态资源访问,配置文件外置)
284 0
Certbot生成Lets Encrypt免费证书并配置到Spring Boot
Certbot生成Lets Encrypt免费证书并配置到Spring Boot
161 0
Spring Boot中的Mybatis分页插件-pagehelper的使用
Spring Boot中的Mybatis分页插件-pagehelper的使用
94 0
一招学会—Spring Boot使用PageHelper进行分页
一招学会—Spring Boot使用PageHelper进行分页
123 0
Spring boot 使用 ON DUPLICATE KEY UPDATE属性控制版本 更新数据不成功
如果更新不成功会报下面的错误(此错误是自定义的): The data you want to update has been updated by another user. Please reopen and try again! 一、主要按下面的流程检查: 1、检查数据库的段alastupdatetime定义 2、检查.xml的alastupdatetime 3、要更新数据的主键是否在同一个updateByBatch中的List中重复出现
89 0
+关注
java技术栈
Java技术栈是一个以 Java 技术为主的原创技术公众号。分享技术包括但不限于 Java 核心技术、多线程编程、Spring Boot、Spring Cloud、缓存、消息队列、架构设计等各种技术干货、Java 面试题、各种技术教程、行业动态等。
文章
问答
文章排行榜
最热
最新
相关电子书
更多
电商网站需求分析和架构设计Spring Boot2.6入门
立即下载
云上Docker的Spring Cloud微服务应用实践分享
立即下载
Spring Boot 2.6.0电商网站开发实战
立即下载