目录
一、自定义banner
生成banner网站:Spring Boot banner在线生成工具,制作下载英文banner.txt,修改替换banner.txt文字实现自定义,个性化启动banner-bootschool.net
修改springboot的配置文件
#修改为自己定义的banner spring.banner.location=classpath:banner.txt #banner的模式 spring.main.banner-mode=off
测试结果:
二、 自定义SpringApplication
方式一:
@SpringBootApplication public class Boot3FeaturesApplication { public static void main(String[] args) { //SpringApplication:springboot应用的核心API入口 //SpringApplication.run(Boot3FeaturesApplication.class, args); //自定义SpringApplication的底层设置 SpringApplication application = new SpringApplication(Boot3FeaturesApplication.class); //设置banner,如果配置文件配置了以配置文件优先 application.setBannerMode(Banner.Mode.CONSOLE); //运行程序 application.run(args); } }
方式二:FluentBuilder API
public static void main(String[] args) { //通过Builder方式构建 new SpringApplicationBuilder() .main(Boot3FeaturesApplication.class) .sources(Boot3FeaturesApplication.class) .bannerMode(Banner.Mode.CONSOLE) .run(args); } }