6.玩转Spring Boot 自定义Banner
来源:互联网 发布:闲来麻将服务器源码 编辑:程序博客网 时间:2024/05/17 05:58
玩转Spring Boot 自定义Banner
到这里相信大家应该都见过以下图案。
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.4.2.RELEASE)
该图案是在启动Spring Boot的时候在控制台输出的,包含当前使用的Spring Boot的版本,有的时候需要定制自己的Banner,也可能关闭输出Banner。接下来介绍如何更改。
1.关闭Banner
在启动的时候调用setBannerMode设置即可,代码如下:
public static void main(String[] args) throws Exception {SpringApplication springApplication = new SpringApplication(SampleController.class);springApplication.setBannerMode(Banner.Mode.OFF);springApplication.run(args);}
Banner.Mode是个内部枚举,有三个值如下:
enum Mode {/** * Disable printing of the banner. 关闭Banner打印输出 */OFF,/** * Print the banner to System.out. 打印Banner 控制台 */CONSOLE,/** * Print the banner to the log file. 打印banner 到日志文件 */LOG}
2.更改Banner
(1)在src/main/resources下新建banner.txt,在该文件中输入你想要的图案即可 。在看《JavaEE开发的颠覆者 Spring Boot实战》一书的时候,作者在书中写了一个网站,可以生成相应的图案,具体大家去试试,网址:http://patorjk.com/software/taag。在banner.txt文件中,你可以使用以下的占位符获取当前应用版本等信息,具体如下:
VariableDescription${application.version}The version number of your application as declared in MANIFEST.MF
formatted for display (surrounded with brackets and prefixed with v).
For example (v1.0).${application.formatted-version}The version number of your application as declared in MANIFEST.MF
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 1.4.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 (v1.4.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.
(2)或者通过springApplication.setBanner(banner);方法,实现Banner接口也一样。
formatted for display (surrounded with brackets and prefixed with v).
For example (v1.0).${application.formatted-version}The version number of your application as declared in MANIFEST.MF
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 1.4.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 (v1.4.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.
(2)或者通过springApplication.setBanner(banner);方法,实现Banner接口也一样。
有兴趣的朋友可以加群探讨相互学习:
Spring Boot QQ交流群:599546061
0 0
- 6.玩转Spring Boot 自定义Banner
- spring boot 自定义banner
- Spring Boot自定义Banner
- Spring Boot自定义Banner
- 新年彩蛋:Spring Boot自定义Banner
- 新年彩蛋:Spring Boot自定义Banner
- 新年彩蛋:Spring Boot自定义Banner
- Spring Boot笔记之自定义启动banner
- spring boot更换banner
- Spring boot 定制banner
- spring boot banner 源码解析
- 定制Spring Boot的Banner
- 关闭spring boot的banner
- spring boot中的banner制作
- spring boot banner的设置
- 玩转Spring Boot 使用Spring security
- 5.玩转Spring Boot 自定义配置、导入XML配置与外部化配置
- 1.玩转Spring Boot 前言
- strlen().printf()和scanf()函数
- EventBus使用以及源码分析
- python爬虫初试
- Android自定义控件
- Java中StringBuilder清空数据方法比较
- 6.玩转Spring Boot 自定义Banner
- Linux:vim主要命令总结
- JAVA中泛型的理解
- Mysql通信协议
- Android系列之网络(二)----HTTP请求头与响应头
- 寻找倍数
- HIVE表数据导出至本地文件系统
- JDK动态代理用法
- 前端开发工作流与构建工具