如何禁用弹簧启动标志在标准输出?

有没有办法禁用可爱但非常明显的 ASCII Spring 启动标志:

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

每次运行一个春季启动应用程序,都会被丢进 STDOUT?

我在 logback.xml 中将所有的日志记录都切换到 ERROR,但是没有任何效果:

<root level="ERROR">
<appender-ref ref="STDOUT" />
</root>

编辑: 在文档中它不叫“ Logo”。搜索友好的术语是“横幅”。

36495 次浏览

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.

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

You can set spring.main.show_banner=false in your application.properties as described in http://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html.

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)

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'

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

spring:
main:
banner-mode: "off"

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);


}


}

To remove this:

1) spring.main.banner-mode=off

Add above line in the file

application.properties

OR

2) USE this in Main java class

setBannerMode(Banner.Mode.OFF);

OR

3) in-app*.yml file

spring:
main :
banner-mode=off

User This Link for More Details

http://mytechnologythought.blogspot.com/2017/07/how-to-remove-spring-boot-banner.html