You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何关闭Spring Boot启动Banner

禁用Spring Boot启动Banner的几种方法

下面是几种常用的禁用Spring Boot启动Banner的方式:

  • 代码配置方式
    在应用的启动类中,通过SpringApplication的API直接关闭Banner:

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

    也可以用链式调用简化写法:

    @SpringBootApplication
    public class DemoApplication {
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args, SpringApplication::setBannerModeOff);
        }
    }
    
  • 配置文件方式
    在application.properties中添加配置:

    spring.main.banner-mode=off
    

    或者在application.yml中添加:

    spring:
      main:
        banner-mode: off
    
  • 命令行参数方式
    启动应用时,在命令行中添加参数:

    java -jar your-app.jar --spring.main.banner-mode=off
    

内容的提问来源于stack exchange,提问作者IMJS

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 00:48:09