banner输出的方式
1、默认banner输出
就是spring boot
2、文字banner。修改banner图
在resources下创建banner.txt 。内容为
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
佛祖保佑 永无BUG
*/
然后运行SpringBoot项目
可以看到打印已经变了
将banner.txt 修改为favorite.txt , 这样就没有效果了,需要在
application.properties 配置spring.banner.location=favorite.txt才有效果。
3、图片banner。 使用图片做banner
在resources下创建banner.jpg
启动项目后打印效果如下:
如果将banner.jpg改成favorite.jpg执行在application.properties 中设置spring.banner.image.location=favorite.jpg
4、兜底banner。使用代码配置banner
public class Sb2Application {
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(Sb2Application.class);
springApplication.setBanner(new ResourceBanner(new ClassPathResource("favorite.txt")));
springApplication.addListeners(new SecondListener());
springApplication.run(args);
}
}
5、关闭banner的打印。在application.properties配置如下
spring.main.banner-mode=off