1:在Application的main方法中,只能控制显示不显示,不能修改内容
public static void main(String[] args) throws Exception { SpringApplication application = new SpringApplication(Example.class); /* * Banner.Mode.OFF:关闭; * Banner.Mode.CONSOLE:控制台输出,默认方式; * Banner.Mode.LOG:日志输出方式; */ //application.setBannerMode(Banner.Mode.OFF); application.run(args); }
2 在src/main/resouces下新建banner.txt,可以修改banner内容显示
http://patorjk.com/software/taag 国外的在线软件,能编辑任何文字 不通格式。
┬┴┬/ ̄\_/ ̄\
┬┴┬┴▏ ▏▔▔▔▔\
┴┬┴/\ / ﹨
┬┴∕ / )
┴┬▏ ● ▏
┬┴▏ ▔█
┴◢██◣ \__/ !
┬█████◣ /
┴█████████████◣
◢██████████████▆▄
█◤◢██◣◥█████████◤\
◥◢████ ████████◤ \
┴█████ ██████◤ ﹨
┬│ │█████◤ ▏
┴│ │ ▏
┬∕ ∕ /▔▔▔\ ∕
┴/___/﹨ ∕ ﹨ /\
#这个是springboot的版本号
${spring-boot.version}
#这个是springboot的版本号
${spring-boot.formatted-version}
3:重写接口Banner实现
SpringBoot提供了一个接口org.springframework.boot.Banner,他的实例可以被传给SpringApplication的setBanner(banner)方法。如果你闲得不行非要着重美化这个命令行输出的话,可以重写Banner接口的printBanner方法。
SpringBoot启动时的Banner设置:
http://somefuture.iteye.com/blog/2247401
4 在application.properties进行配置
在application.proerpties进行banner的显示和关闭:
### 是否显示banner,可选值[true|false]
spring.main.show-banner=false
本文介绍了如何在Spring Boot项目中自定义启动时显示的Banner,包括通过修改main方法、使用外部banner.txt文件、重写Banner接口及配置application.properties来实现。
5060

被折叠的 条评论
为什么被折叠?



