SpringBoot启动时的Banner设置

对于使用过Spring Boot的开发者来说,程序启动的时候输出的由字符组成的Spring符号并不陌生。这个是Spring Boot为自己设计的Banner:

1.    .   ____          _            __ _ _

2.   /\\ / ___‘_ __ _ _(_)_ __  __ _ \ \ \ \

3.  ( ( )\___ | ‘_ | ‘_| | ‘_ \/ _` | \ \ \ \

4.   \\/  ___)| |_)| | | | | || (_| |  ) ) ) )

5.    ‘  |____| .__|_| |_|_| |_\__, | / / / /

6.   =========|_|==============|___/=/_/_/_/

7.   :: Spring Boot ::        (v1.3.3.RELEASE)

如果有人不喜欢这个输出,本文说一下怎么修改。

第一种方式:修改的时候,进行设置,在Application的main方法中:

SpringApplication application = new SpringApplication(App.class);

/*

* Banner.Mode.OFF:关闭;

* Banner.Mode.CONSOLE:控制台输出,默认方式;

* Banner.Mode.LOG:日志输出方式;

*/

application.setBannerMode(Banner.Mode.OFF);

application.run(args);

第二种方式:修改banner.txt配置文件

在src/main/resouces下新建banner.txt,在文件中加入:

#这个是MANIFEST.MF文件中的版本号

${application.version}

#这个是上面的的版本号前面加v后上括号

${application.formatted-version}

#这个是springboot的版本号

${spring-boot.version}

#这个是springboot的版本号

${spring-boot.formatted-version}

第三种方式:重写接口Banner实现

SpringBoot提供了一个接口org.springframework.boot.Banner,他的实例可以被传给SpringApplication的setBanner(banner)方法。如果你闲得不行非要着重美化这个命令行输出的话,可以重写Banner接口的printBanner方法。

第四种方式:在application.properties进行配置

在application.proerpties进行banner的显示和关闭:

### 是否显示banner,可选值[true|false]

spring.main.show-banner=false

时间: 2024-07-31 05:21:17

SpringBoot启动时的Banner设置的相关文章

Springboot 启动时Bean初始化,启动异常-Assert.isTrue(condition,message) 报错

Springboot 启动时Bean初始化启动异常Assert.isTrue(condition,message) 报错,如果 condition为false 则会出现 java.lang.IllegalArgumentException: message, org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXXXXX' defined in class path re

【问题解决:信息提示】SpringBoot启动时提示The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path

问题描述 springboot程序在启动时提示信息 [2018-10-24 21:59:05.214] - 440 信息 [restartedMain] --- org.apache.catalina.core.StandardService: Starting service [Tomcat] [2018-10-24 21:59:05.220] - 440 信息 [restartedMain] --- org.apache.catalina.core.StandardEngine: Start

springboot启动时控制台不显示映射的URL

背景 今天,第一次使用 2.2.0 版本的springboot,在访问接口时发现访问不到,于是在控制台进行 URL 搜索,发现并相关没有内容 原因 springboot版本差异,切换回 2.0.5.RELEASE ,启动项目,发现控制台又正常打印API了 解决方法 2.2.0 版本中,配置文件中更改 org.springframework.web 包的日志级别: logging: level: org.springframework.web: TRACE 启动项目,查看控制台打印: 总结 Spr

springboot启动时的一个bug

项目启动就有这个错 Error creating bean with name 'XXXXXXXX': Cannot create inner bean '(inner bean)#1f930774' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager 这虽然是个警告但是就是起不来 2019-06-16 22:13:58.504 WA

SpringBoot在启动时的多环境配置以及加载顺序

通常我们在开发完成一个SpringBoot项目时,总是要打包部署的. 在启动SpringBoot应用时,我们常常会使用命令java -jar xxx.jar来启动这个服务. 命令java -jar 除了启动应用之外,还可以在命令中指定应用的参数,比如一下带参数的命令: (1)java -jar xxx.jar --server.port=8081,直接以命令的方式来设置服务的访问端口server.port属性,将端口设置为8081; (2)java -jar -Xms1024m -Xmx1024

SpringBoot启动过程原理

最近这两年springboot突然火起来了,那么我们就来看看springboot的运行原理. 一.springboot的三种启动方式: 1.运行带有main方法的2.通过命令 Java -jar命令3.通过spring-boot-plugin的方式 二.springboot 启动时执行方法,有两种方式 第一种方式是用启动时的main方法加载静态方法. 另一种是用初始化注解@postconstruct 执行.(注意点必须void并且参数). 注意点:[1.@PostConstruct会先被执行,静

springboot启动过程(1)-初始化

1   springboot启动时,只需要调用一个类前面加了@SpringBootApplication的main函数,执行SpringApplication.run(DemoApplication.class, args)即可,这里初始化了一个SpringApplication实例,然后调用run启动springboot.run方法中,调用了initialize,如下 @SuppressWarnings({ "unchecked", "rawtypes" }) p

springboot启动报错退出,To display the conditions report re-run your application with 'debug' enabled.

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2019-01-19 12:01:39.870 ERROR 8324 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : ***************************APPLICATIO

系统属性file.encoding在JVM启动后,再次设置无法对系统的默认编码造成影响

原因和解决方法: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4163515 https://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding/362006#362006 file.encoding由谁设置? 首先file.encoding是一个系统属性.可以在启动JVM 前设置 如: java -Dfile.encoding=