您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

怎么修改SpringBoot项目启动banner

2024/6/5 1:53:38发布35次查看
如果我们使用过springboot,那么就会对下面的图案不陌生。springboot 启动的同时会打印下面的图案,并带有版本号。
查看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会出现下面提示,正对应上面翻译的内容。
1、自定义banner
我们在类路径下新建banner.txt文件,绘制下面图案。
springboot项目启动后如下,这样我们就修改了banner。
我们暂时删除banner.txt文件,将下面图片放置在类路径下,名称为:banner.jpg。
然后在配置文件中配置如下内容
启动springboot项目后,图案如下所示,springboot把图片转成 ascii图案。
如果我们不想在启动时出现图案,那么就需要修改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的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product