Spring Boot 2.0 (ii): Spring Boot 2.0 early adopters-Dynamic Banner

Source: Internet
Author: User

Spring Boot 2.0 offers a number of new features, one of which is a small egg: dynamic Banner, and today we'll take this to taste fresh.

Configuration dependencies

With spring boot 2 You first need to replace the project dependency package with the newly released 2.0 release, and now the site https://start.spring.io/ also sets Spring Boot 2.0 as the default version.

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

When Setup is complete, dependencies there is no dependent package specified in the version, and the 2.0.0.RELEASE dependent version is automatically used.

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

Spring Boot 2.0 has just been released, some MAVEN repositories have not been updated, and if dependency packages cannot be downloaded after importing the project, you can manually add the Spring boot official Maven repository.

<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>

Get ready for the first time using Spring Boot 2.0, the full dependency package needs to download about half an hour.


Spring Boot Replacement Banner

Let's go back to the Spring Boot 1.0 How to replace the boot Banner, in fact, is very simple, just need to src/main/resources create a new file under the path banner.txt , banner.txt fill in the string content that needs to be printed.

In general, we use third-party tools to help transform content, such as Web sites that convert http://www.network-science.de/ascii/ text into strings, websites: http://www.degraeve.com/img2txt.php You can convert images into strings.

Let's test with Hello World for the startup string:

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

src/main/resourcesCreate a new file under the Spring Boot 2.0 project path, banner.txt paste the string above, start the Spring Boot project observation boot log, and discover that Spring Boot 2.0 has replaced the default spring string with Hello Worl D. Description Spring Boot 2.0 also supports 1.0 ways to replace Banner.

Next, test the print dynamic Banner in the Spring Boot 2.0 project using the following GIF:

Also we put the Banner.gif file in the project src/main/resources path, start the project to test, output column print information as follows:

                                                                                                                          ..                                                                           .::*                                                                                                                                                                                                                          ...                                                             .....    ....        ........                                                            . ...  ........                                                                .  .. ......                                                                  ....  ....                                                                     ...  .                                                                                                                                                                                                                   . ..                                                                  **::**..                                                               .*::::::::::*.                                                              .*::::::::::::*.                  .*::::::::::::*.                                            .*::::::::::::*.                                                                  .*::::::::::*. ..                                                                                                                                                                                                                                           **::***.                                                                            ..                                                                     .....  ..                                              .....                      ...  ......                                                                ......  .                                                             ...    .       .....  . ....                                                             .                . ............................   .............                                .................. .........       ...........                  .....    . ...................                   ... . ... ............               .............   .   ...                             ...............            .                                            .........                                         ...........                ..........                                                     ....... ....           ............                                                ........          ........                                                        ........       .... .                          .........      ........                              ........    .........                       ..                      ********..  ......*.. ........                      .                    **::::::::::::**. ........  ...........                 .                   **::::::::::::::::**. .......  ......                     .                  *::::::::::::::::::::*.                    .......  ... ..                 .*::::::::::::::::::::::*.                 .......  ......                    .::::::::::::::::::::::::.                .......  ..........                .::::::::::::::::::::::::. ... ....  .........                 .                    *:::::::::::::::::::::::. ....  .........                 .                     *::::::::::::::::::::::*. ...  .........                  .                     *::::::::::::::::::::*. ....   ........                   .                 **::::::::::::::::**. .........    ... ....                    .                   **::::::::::::**. .........  .             ........           .********..                                                      .........     ....... .      ......*..   .........                                                     .                                          .....        .......                                                    .........          ........     .                                        ............          ............  .. ...........             .                              .............                                        .........               ................                   ....   ..........                 ............. ....    . ......... .                  ..... . .... ...... .........       . ..       .... .............. ....                       ..                                                                                                                                                                                    .............  ...........  ..............                                                                                                   ::.        .*:*                                                            :. *:*      *.    .*:*                                                 .:*.       *:   .*:*.   :.                .:                                          :* :     :.                                  .::::*    :                                      :  :    *         *****.....       *.:   :     :   : .:*         .::::::::::**..  ..     : *                                :   *:           .*:::::::::::::::*.   * * * * * * * * .... * *::-:::::::* *.   *   :.:                           : .* :    .....***::::::::::::::::::::::*.  :: O:*. *   ..   *****:::::::::::::::::::::::::*.   *: o:.    .*::::::::::::::::::::::::::::::::*.      :: *:*: *:.::::::----::-::-----                * O *.-:::::::::::---------:--------  .: o   :                      :  : :   .*::::::::::::::::::::::::::::::::::*. :  .    :                      :  ..   .*::::::::::::::::::::::::::::::::::*.   *  : *                      :   :    .*::::::::::::::::::::::::::::::::::*   :   *:                       .   :*. *o:::-::::::::::::::::-----------:---------:*.   .   :                         :  :  *   .*::::::::::::::::::::::::::::::*.    *:* O *:. *:::::::::::-:--::------------------    : ** :                            :*   *    .*::::::::::::::::::::::::**.  *.. *                              **   *    ..     *::::::::::::::::::::*..     :* * * O.. ..    **::::::::::::**.. .:.   ::: O.: ... *. ******.                                     :  :.                ::: o:.    *:     * *:                                          :.   :       .*:*.     :*    .*::                                            .:*. * *o:.:        .:*.                                                                       .*:                                                                           ...

With the above output we find that spring boot will start with each picture of the GIF, printed in sequence in the log, and the Spring boot project will not start until all the pictures have been printed.

If the directory src/main/resources exists at the same time banner.txt , the banner.gif project will print banner.gif banner.txt the contents of each screen before printing.

What is the use of the project launch Banner, in some large organizations or companies, you can use this feature to customize their own splash screen, increase the team's brand identity.

Sample Code-github

Sample code-Cloud Code

Reference

Demo-animated-banner

Spring Boot 2.0 (ii): Spring Boot 2.0 early adopters-Dynamic Banner

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.