Provide Best Programming Tutorials

Springboot Banner

This article will show you how to use springboot banner.

Springboot banner can show the message and image when you start the springboot application.

project structure

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>spring-boot-banner</artifactId>
  <version>2.0.0</version>
  <packaging>jar</packaging>

  <name>Spring Boot banner</name>
  <description>A very useful project to demonstrate animated gif support in Spring Boot 2</description>

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

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>

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

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

</project>

banner.txt

You can put the message you wanna display when the application starts. The application will automatically read the content inside this file and display it in the terminal.

In this case, I put below content inside this file.

____ _  _ ___  ____ ____ _ _ _
|__| |\ | |  \ |__/ |___ | | |
|  | | \| |__/ |  \ |___ |_|_|

___  ____ ____ ____ ____ ____ _  _ _  _ _ _  _ ____
|__] |__/ |  | | __ |__/ |__| |\/| |\/| | |\ | | __
|    |  \ |__| |__] |  \ |  | |  | |  | | | \| |__]

banner.gif

This is the image you wanna display when the application starts. The application will automatically read the content inside this file and display it in the terminal.

Note:If there has both banner.gif and banner.txt then the application will read them both and display them in the following order:

  1. read the banner.gif
  2. read the banner.txt

running result

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

 

Source Code

Download Address:https://github.com/AndrewProgramming/springbootTutorialCode/tree/master/spring-boot-banner

 

 

 

 

Leave a Reply

Close Menu