如何在stdout中禁用Spring Boot徽标?

5 浏览
0 Comments

如何在stdout中禁用Spring Boot徽标?

有没有方法可以禁用Spring Boot很可爱但非常明显的ASCII标志:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.1.8.RELEASE)

...每次运行Spring Boot应用程序时都会在STDOUT中打印出来?

我在我的logback.xml中将所有日志记录切换为ERROR,但没有任何作用:

    

编辑:在文档中它不被称为“标志”。 可以使用“横幅”这个搜索友好的术语。

admin 更改状态以发布 2023年5月21日
0
0 Comments

另一个选择是在类路径中添加自定义横幅的banner.txt文件,这将更改为您的自定义横幅。

  1. 在类路径(src/main/resources)中创建一个名为banner.txt的文件
  2. 编辑您的自定义横幅
  3. 运行应用程序
0
0 Comments

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
在较新版本的Spring Boot中(当前为1.3.3),方法如下:

1)application.properties文件中:

spring.main.banner-mode=off

2)application.yml文件中:

spring:
    main:
        banner-mode: "off"

3)主方法:

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

文档

编辑:

要使用环境变量来更改此设置,请使用下划线代替点的属性。例如:

SPRING_MAIN_BANNER-MODE=off

有关外部配置,请参阅文档

0