Spring Boot - How to change the default banner.

In SpringBoot, the banner image can be customised to use a particular image.

The spring application uses the imagebanner to define the icon to display, that image can be created using a file system resource.

Banner banner = new ImageBanner(new FileSystemResource( "FILE.png" )  );
app.setBanner( banner );

1- Create the following java file:

import java.util.Properties;

import org.springframework.boot.Banner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.ImageBanner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.core.io.FileSystemResource;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@EnableJpaRepositories
@EnableAutoConfiguration
public class StaticGenerator3 implements CommandLineRunner {

    
    public static void main(String[] args) throws Exception {

	SpringApplication app = new SpringApplication(StaticGenerator3.class);

	app.setBannerMode(Banner.Mode.LOG );
        Banner banner = new ImageBanner(new FileSystemResource( "V:/tmp/favicon-16x16.png" )  );
        app.setBanner( banner );
        
        Properties props = new Properties();
        app.setDefaultProperties(props);
        
        // Call the run method
        app.run(args);

    }

    @Override
    public void run(String... args) throws Exception {
	    // Put your logic here.

    }
}

In this example the favicon is the ImageBanner, the output of the java process shows the o displayed using ascii characters.

The output will be:

2018-12-19 12:12:25.984  INFO 4884 --- [           main] o.s.boot.SpringApplication               : 

                     .....::::ooooooooooooooooooo:::::.....                   
                     .....::::ooooooooooooooooooo:::::.....                   
                :::::oooooooooooooooooooooooooooooooooooooo:::::              
                :::::oooooooooooooooooooooooooooooooooooooo:::::              
                :::::oooooooooooooooooooooooooooooooooooooo:::::            

References:

Java 8
Spring Boot