New features of Spring Boot 2.0 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> span class= "kw" ><artifactid>spring-boot-starter-parent< span class= "kw" ></artifactid> <version>2.0.0.release</< Span class= "Hljs-name" >version></parent                 

After the

is set, the dependencies does not have a dependent package in the specified 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> << Span class= "Hljs-name" >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's src/main/resources path, start the project to test, output column printing 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.

Amateur grass Share 100 sets of selected 1000G architect materials courses (super 1T of it learning materials sent free).

More than 1024G of it learning materials for free, you deserve to have!

Receive resources, follow the "amateur grass" public number, reply to the corresponding keywords

    • 01, reply "I want Health", get programmer health, connotation package!
    • 02, reply "Big Data", get big data related resources.
    • 03, reply to "Linux", to obtain information about Linux.
    • 04, Reply to "MongoDB", access to MongoDB learning materials.
    • 05. Reply to "Redis" to obtain information about Redis.
    • 06, reply "Zookeeper", get distributed and other related information.
    • 07, reply "Dubbo", get Dubbo related information.
    • 08, reply "Git", get git data
    • 09, reply "design mode", get design pattern material
    • 10, reply to "small program", get the information related to the small program
    • 11, reply "Android", get information about Android
    • 12, reply to "Java", get Java related information
    • 13, reply "Pyhton", get Pyhton related information.
    • 14, reply "Springboot", get the spring boot related material.
    • 15. Reply to "Springcloud" to get information about spring cloud.

This article source code download: https://github.com/ityouknow/spring-boot-examples

New features of Spring Boot 2.0 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.