how to disable spring boot logo in stdout?

后端 未结 8 677
名媛妹妹
名媛妹妹 2021-01-30 19:08

Is there a way to disable the lovely but very visible ASCII Spring boot logo :

  .   ____          _            __ _ _
 /\\\\ / ___\'_ __ _ _(_)_ __  __ _ \\ \\          


        
相关标签:
8条回答
  • 2021-01-30 19:41

    This has changed slightly in Spring Boot 1.3. The property is now:

    spring.main.banner_mode=off
    

    In code, it is now:

    springApplication.setBannerMode(Banner.Mode.OFF);
    

    or using the builder:

    new SpringApplicationBuilder()
    .bannerMode(Banner.Mode.OFF)
    
    0 讨论(0)
  • 2021-01-30 19:45

    You can use this code to remove banner

    import org.springframework.boot.Banner;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    
    
    public class SpringBootConsoleApplication {
    
        public static void main(String[] args) throws Exception {
    
            SpringApplication app = new SpringApplication(SpringBootConsoleApplication.class);
            app.setBannerMode(Banner.Mode.OFF);
            app.run(args);
    
        }
    
    }
    
    0 讨论(0)
  • 2021-01-30 19:46

    http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-banner

    new SpringApplicationBuilder()
        .showBanner(false)
        .sources(Parent.class)
        .child(Application.class)
        .run(args);
    

    Edit In the newer versions of spring boot(current is 1.3.3) the way to do it is:

    1) application.properties

    spring.main.banner-mode=off

    2) application.yml

    spring:
        main:
            banner-mode: "off"
    

    3) main method

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

    Docs

    Edit:

    To change this with and environment variable use the property with underscore instead of dot. Try:

    SPRING_MAIN_BANNER-MODE=off

    See the docs for externalized config.

    0 讨论(0)
  • 2021-01-30 19:46

    create a file "application.yml" under src/main/resources" and paste the below code.That would do the job

    spring:
        main:
            banner-mode: "off"
    
    0 讨论(0)
  • 2021-01-30 19:48

    Another option is adding custom banner in a banner.txt file to your classpath, that will change to your custom banner.

    1. create a file banner.txt in the classpath (i.e: src/main/resources)
    2. Edit you custom banner
    3. Run the application
    0 讨论(0)
  • 2021-01-30 19:52

    If you are using Spring Boot 1.3 and application.yml (not properties) then you need to quote the 'OFF' i.e.

    spring:
      main:
        banner_mode: 'OFF'
    
    0 讨论(0)
提交回复
热议问题