Total Pageviews

2020/01/03

[Spring Boot] How to disable Spring logo banner

Problem
When starting my Spring Boot project, I always have Spring logo banner as bellows:



How-To
You need to modify spring main class.
As-is
package com.esb.batch;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.Banner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@Slf4j
@SpringBootApplication
public class BatchApplication implements CommandLineRunner {

    public static void main(String[] args) {
         SpringApplication.run(BatchApplication.class, args);
    }

}


To-be (set banner mode to off):
package com.esb.batch;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@Slf4j
@SpringBootApplication
public class BatchApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(BatchApplication.class);
        app.setBannerMode(Banner.Mode.OFF);
        app.run(args);
    }
    
}


Check the result:





No comments: