配置依赖

使用 Spring Boot 2.0 首先需要将项目依赖包替换为刚刚发布的 2.0 RELEASE,现在网站https://start.spring.io/也将 Spring Boot 2.0 设置为默认版本。

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>

设置完毕后,dependencies中没有指明版本的依赖包,将自动使用2.0.0.RELEASE依赖的版本。

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>

Spring Boot 2.0 刚刚发布,一些 Maven 仓库还没更新,如果导入项目后依赖包不能下载,可以手动添加 Spring Boot 官方 Maven 仓库。

<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

大家做好心理准备,第一次使用 Spring Boot 2.0 ,完整依赖包需要下载半小时左右。

Spring Boot 更换 Banner

我们先来回顾一下在 Spring Boot 1.0 中如何更换启动 Banner,其实都很简单,只需要在src/main/resources路径下新建一个banner.txt文件,banner.txt中填写好需要打印的字符串内容即可。

一般情况下,我们会借助第三方工具帮忙转化内容,如网站http://www.network-science.de/ascii/将文字转化成字符串,网站:http://www.degraeve.com/img2txt.php可以将图片转化成字符串。

我们以Hello World为启动字符串来进行测试:

.__           .__  .__                               .__       .___
| |__ ____ | | | | ____ __ _ _____________| | __| _/
| | \_/ __ \| | | | / _ \ \ \/ \/ / _ \_ __ \ | / __ |
| Y \ ___/| |_| |_( <_> ) \ ( <_> ) | \/ |__/ /_/ |
|___| /\___ >____/____/\____/ \/\_/ \____/|__| |____/\____ |
\/ \/ \/

在 Spring Boot 2.0 项目src/main/resources路径下新建一个banner.txt文件,粘贴上述字符串,启动 Spring Boot 项目观察启动日志,发现 Spring Boot 2.0 已经将默认的 Spring 字符串替换为 hello world。说明 Spring Boot 2.0 也支持1.0更换 Banner 的方法。

接下来在 Spring Boot 2.0 项目中测试打印动态 Banner ,使用的gif如下:

同样我们将 banner.gif 文件放到项目的src/main/resources路径下,启动项目进行测试,输出栏打印信息如下:



                                        ..
.::*
... ..... ....
........ . ...
........ . ..
...... ....
.... ...
. . ..**::**..
.*::::::::::*.
.*::::::::::::*.
.*::::::::::::*.
.*::::::::::::*.
.*::::::::::*.
..**::***. ..
..... ..
..... ...
...... ......
. ... . .....
. .... . . ............................ .............
.................. ......... ................ .
................... ... . ... ............
............. . ... ...............
. ......... ...........
.......... ....... ....
............ ........
........ ........
.... . .........
........ ........
......... ..********.. ......*..
........ .**::::::::::::**. ........
........... .**::::::::::::::::**. .......
...... .*::::::::::::::::::::*. .......
... .. .*::::::::::::::::::::::*. .......
...... .::::::::::::::::::::::::. .......
.......... .::::::::::::::::::::::::. ... ....
......... .*:::::::::::::::::::::::. ....
......... .*::::::::::::::::::::::*. ...
......... .*::::::::::::::::::::*. ....
........ .**::::::::::::::::**. .........
... .... .**::::::::::::**. .........
. ........ .********.. .........
....... . ......*..
......... . .....
....... .........
........ . ............
............ .. ...........
. ............. .........
................ .... ..........
............. .... . ......... . ..... .
.... ...... ......... . .. .... .............. ....
.. ............. ........... .............. ::. .*:*
:. *:* *. .*:*
.:*. *: .*:*. :. .:
:* : :. .::::* :
: : * *****..... *.: :
: : .:* .::::::::::**.. .. : *
: *: .*:::::::::::::::*. * **
o *** ...**::::::::::::::::::**. * :.:
: .* : .....***::::::::::::::::::::::*. : : o
:*. * ..*****:::::::::::::::::::::::::*. * : o
: . .*::::::::::::::::::::::::::::::::*. :: *
:* : *::::::::::::::::::::::::::::::::::* : o
* o * .*::::::::::::::::::::::::::::::::::*. .:o :
: : : .*::::::::::::::::::::::::::::::::::*. : . :
: .. .*::::::::::::::::::::::::::::::::::*. * : *
: : .*::::::::::::::::::::::::::::::::::* : *:
. :* .*o:::::::::::::::::::::::::::::::*. . :
: : * .*::::::::::::::::::::::::::::::*. * :*
o * : .*::::::::::::::::::::::::::::*. : ** :
:* * .*::::::::::::::::::::::::**. *.. *
** * ..*::::::::::::::::::::*.. :* *
* o .. ..**::::::::::::**.. .:. : :
: o.: ...******... *. : :.
: ::o:. *: * *:
:. : .*:*. :* .*::
.:* .* *o: .:
.:*. .*: ...

通过上述输出我们发现 Spring Boot 在启动的时候,会将 gif 图片的每一个画面,按照顺序打印在日志中,所有的画面打印完毕后,才会启动 Spring Boot 项目。

如果目录src/main/resources下同时存在banner.txtbanner.gif,项目会先将banner.gif每一个画面打印完毕之后,再打印banner.txt中的内容。

项目的启动 Banner 有什么用呢,在一些大的组织或者公司中,可以利用这个特性定制自己专属的启动画面,增加团队对品牌的认同感。

Spring Boot 2.0尝鲜-动态 Banner的更多相关文章

  1. Spring Boot 2.0(二):Spring Boot 2.0尝鲜-动态 Banner

    Spring Boot 2.0 提供了很多新特性,其中就有一个小彩蛋:动态 Banner,今天我们就先拿这个来尝尝鲜. 配置依赖 使用 Spring Boot 2.0 首先需要将项目依赖包替换为刚刚发 ...

  2. Spring Boot 2.0(一):Spring Boot 2.0尝鲜-动态 Banner

    Spring Boot 2.0 提供了很多新特性,其中就有一个小彩蛋:动态 Banner,今天我们就先拿这个来尝尝鲜 Spring Boot 更换 Banner 我们先来回顾一下在 Spring Bo ...

  3. (转)Spring Boot 2 (二):Spring Boot 2 尝鲜-动态 Banner

    http://www.ityouknow.com/springboot/2018/03/03/spring-boot-banner.html Spring Boot 2.0 提供了很多新特性,其中就有 ...

  4. Spring Boot 2 (二):Spring Boot 2 尝鲜-动态 Banner

    Spring Boot 2.0 提供了很多新特性,其中就有一个小彩蛋:动态 Banner,今天我们就先拿这个来尝尝鲜. 配置依赖 使用 Spring Boot 2.0 首先需要将项目依赖包替换为刚刚发 ...

  5. spring boot 2.0(二)动态banner的支持

    Spring Boot 2.0 提供了很多新特性,其中就有一个小彩蛋:动态 Banner,今天我们就先拿这个来尝尝鲜. 配置依赖 使用 Spring Boot 2.0 首先需要将项目依赖包替换为刚刚发 ...

  6. springboot2.0(一):【重磅】Spring Boot 2.0权威发布

    就在昨天Spring Boot2.0.0.RELEASE正式发布,今天早上在发布Spring Boot2.0的时候还出现一个小插曲,将Spring Boot2.0同步到Maven仓库的时候出现了错误, ...

  7. 业余草分享 Spring Boot 2.0 正式发布的新特性

    就在昨天Spring Boot2.0.0.RELEASE正式发布,今天早上在发布Spring Boot2.0的时候还出现一个小插曲,将Spring Boot2.0同步到Maven仓库的时候出现了错误, ...

  8. Spring Boot 2.0系列文章(七):SpringApplication 深入探索

    关注我 转载请务必注明原创地址为:http://www.54tianzhisheng.cn/2018/04/30/springboot_SpringApplication/ 前言 在 Spring B ...

  9. Spring Boot 2.0 教程 - 深入SpringAplication

    原文连接:https://www.codemore.top/cates/Backend/post/2018-05-20/spring-boot-SpringApplication 可以通过Spring ...

随机推荐

  1. Excel Vlookup使用

    VLookup用途 作用:关联两张表数据显示 如A表有字段id, name, B表有字段id, sex, 要把两张表合并成id, name, sex 操作步骤 1,在A表后面新增列sex 2, 插入公 ...

  2. 2018-2019-2 20175211 实验一《Java开发环境的熟悉》实验报告

    目录 代码托管 一.命令行下Java程序开发 二.IDEA下Java程序开发.调试 (1)建立与Git的链接 (2)开发.调试程序 (3)上传代码至码云 三.练习 四.问题及解决 五.学习总结 代码托 ...

  3. python安装包API文档

    在python开发过程中,经常会使用第三方包,或者内置的包. 那么这些包,具体有哪些选项,有哪些方法,你知道吗?下面介绍一种万能方法. 使用命令:<注意,命令里python显示的API版本是根据 ...

  4. vue2Leaflet使用 Vue2Leaflet-master 的demo

    首先下载该demo 地址:https://github.com/KoRiGaN/Vue2Leaflet 下载后可以运行里面的例子,在examples文件夹内,该文件夹本身就是一个完整的项目 然后cmd ...

  5. day04 一个简单的代码优化案例

    import random punches = ['石头','剪刀','布'] computer_choice = random.choice(punches) user_choice = input ...

  6. [openjudge-搜索]城堡问题(The Castle)

    题目描述 描述 图1是一个城堡的地形图.请你编写一个程序,计算城堡一共有多少房间,最大的房间有多大.城堡被分割成mn(m≤50,n≤50)个方块,每个方块可以有0~4面墙. 输入 程序从标准输入设备 ...

  7. 洛谷P1605 迷宫 (DFS)

    题目背景 迷宫 [问题描述] 给定一个N*M方格的迷宫,迷宫里有T处障碍,障碍处不可通过.给定起点坐标和 终点坐标,问: 每个方格最多经过1次,有多少种从起点坐标到终点坐标的方案.在迷宫 中移动有上下 ...

  8. Porsche Piwis Tester II V14.000 with CF30 Laptop at autonumen.com

    Porsche piwis tester ii is the latest professional tester for Porshe,the most poweful diagnose and o ...

  9. ELK学习笔记之基于kakfa (confluent)搭建ELK

    0x00 概述 测试搭建一个使用kafka作为消息队列的ELK环境,数据采集转换实现结构如下: F5 HSL–>logstash(流处理)–> kafka –>elasticsear ...

  10. 浅析Tomcat、JBOSS、WebSphere、WebLogic、Apache

    做任何web项目,都离不开服务器,有钱的公司用WebSphere.WebLogic,没钱公司用nginx+tomcat,不要小瞧nginx+tomcat麻雀虽小,五脏俱全. 服务器的知识,在笔试.面试 ...