网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

怎么修改SpringBoot项目启动banner-创新互联

这篇文章主要介绍“怎么修改SpringBoot项目启动banner”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“怎么修改SpringBoot项目启动banner”文章能帮助大家解决问题。

创新互联主营东至网站建设的网络公司,主营网站建设方案,成都app软件开发公司,东至h5小程序制作搭建,东至网站营销推广欢迎东至等地区企业咨询

如果我们使用过SpringBoot,那么就会对下面的图案不陌生。Springboot 启动的同时会打印下面的图案,并带有版本号。


怎么修改SpringBoot项目启动banner

查看SpringBoot官方文档可以找到关于 banner 的描述

The banner that is printed on start up can be changed by adding a banner.txt file to your classpath or by setting the spring.banner.location property to the location of such a file. If the file has an encoding other than UTF-8, you can set spring.banner.charset. In addition to a text file, you can also add a banner.gif, banner.jpg, or banner.png image file to your classpath or set the spring.banner.image.location property. Images are converted into an ASCII art representation and printed above any text banner.

通过有道翻译

可以通过向类路径中添加一个banner.txt文件或设置spring.banner来更改在console上打印的banner。属性指向此类文件的位置。如果文件的编码不是UTF-8,那么可以设置spring.banner.charset。除了文本文件,还可以添加横幅。将gif、banner.jpg或banner.png图像文件保存到类路径或设置spring.banner.image。位置属性。图像被转换成ASCII艺术形式,并打印在任何文本横幅上面。

在IDEA中,在SpringBoot配置文件中输入spring.banner会出现下面提示,正对应上面翻译的内容。


怎么修改SpringBoot项目启动banner

1、自定义banner

我们在类路径下新建banner.txt文件,绘制下面图案。



怎么修改SpringBoot项目启动banner

SpringBoot项目启动后如下,这样我们就修改了banner。


怎么修改SpringBoot项目启动banner

我们暂时删除banner.txt文件,将下面图片放置在类路径下,名称为:banner.jpg。


怎么修改SpringBoot项目启动banner

然后在配置文件中配置如下内容


怎么修改SpringBoot项目启动banner

启动SpringBoot项目后,图案如下所示,Springboot把图片转成 ASCII图案。


怎么修改SpringBoot项目启动banner

如果我们不想在启动时出现图案,那么就需要修改SpringBoot启动类的代码

原代码

public static void main(String[] args) {
  SpringApplication.run(SpringbootShiroApplication.class, args);
}

修改后的代码

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

这样,SpringBoot启动时就不会打印图案了。

关于“怎么修改SpringBoot项目启动banner”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注创新互联行业资讯频道,小编每天都会为大家更新不同的知识点。


本文题目:怎么修改SpringBoot项目启动banner-创新互联
文章URL:http://bjjierui.cn/article/cdocop.html

其他资讯