【SpringBoot】个性化banner.txt了解一下?

在上手springboot之后,可以看到在 启动的时候,控制台会打印出关于springboot的信息,也就是显示出来SpringBoot默认的信息(横幅)。

在springboot的官方文档中指出,可以自定义属于自己的横幅。
https://docs.spring.io/spring-boot/docs/2.0.2.RELEASE/reference/htmlsingle/#boot-features-custom-log-levels
23.2 Customizing the Banner 自定义横幅

可以通过向banner.txt类路径添加文件或将spring.banner.location属性设置为此类文件的位置来更改启动时打印的横幅。如果文件的编码不是UTF-8,则可以进行设置spring.banner.charset。除了一个文本文件,你还可以添加一个banner.gif,banner.jpg或banner.png 图像文件到类路径或设置spring.banner.image.location属性。图像将转换为ASCII艺术表示,并打印在任何文本横幅上方。

在banner.txt文件中,您可以使用以下任何占位符:

VariableDescription
${application.version}The version number of your application, as declared in MANIFEST.MF. For example, Implementation-Version: 1.0 is printed as 1.0.
${application.formatted-version}The version number of your application, as declared in MANIFEST.MF and formatted for display (surrounded with brackets and prefixed with v). For example (v1.0).
${spring-boot.version}The Spring Boot version that you are using. For example 2.0.2.RELEASE.
${spring-boot.formatted-version}The Spring Boot version that you are using, formatted for display (surrounded with brackets and prefixed with v). For example (v2.0.2.RELEASE).
${Ansi.NAME} (or ${AnsiColor.NAME}, ${AnsiBackground.NAME}, ${AnsiStyle.NAME})Where NAME is the name of an ANSI escape code. See AnsiPropertySource for details.
${application.title}The title of your application, as declared in MANIFEST.MF. For example Implementation-Title: MyApp is printed as MyApp.

在项目的resources文件夹下新建一个banner.txt文件,或者自定义文件之后在application.property中指定文件路径。

自定义内容之后,重启项目就好了。

也可以在property文件中,禁止控制台显示banner内容:
spring.main.banner-mode=off

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值