下载Spring-Boot源码,目录结构spring-boot-2.1.0.M2\spring-boot-2.1.0.M2\spring-boot-project\spring-boot\src\main\java\org\springframework\boot

Banner为接口具体实现类二个,https://docs.spring.io/spring-boot/docs/2.0.5.RELEASE/api/

一个存放图片资源,一个存放资源。

package com.jachs.jurisdiction.Jurisdiction;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader; import org.springframework.boot.ImageBanner;
import org.springframework.boot.ResourceBanner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.core.io.InputStreamResource; @SpringBootApplication
public class JurisdictionApplication{
/*
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
System.out.println("in");
try {
builder.banner(new ImageBanner(new InputStreamResource(new FileInputStream("C:\\Users\\Jachs\\Desktop\\a.png"))));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return builder.sources(JurisdictionApplication.class);
}
*/
public static void main(String[] args) throws FileNotFoundException {
// SpringApplication.run(LoginAction.class, args);
// SpringApplication.run(JurisdictionApplication.class, args);
SpringApplication application = new SpringApplication(JurisdictionApplication.class);
application.setBanner(new ImageBanner(new InputStreamResource(new FileInputStream("C:\\Users\\Jachs\\Desktop\\a.png"))));
// application.setBanner(new ResourceBanner(new InputStreamResource(new FileInputStream("C:\\Users\\Jachs\\Desktop\\s.txt"))));
application.run(args);
}
}

实现ImageBanner是打印的为图片二进制,为实现自己独特的打印采用ResourceBanner指定一个文本写入类容初始化时打印。

************************
************************
*******HellWord*********
************************
************************
-- ::21.462 INFO --- [ main] c.j.j.J.JurisdictionApplication : Starting JurisdictionApplication on ZhanChaoHan with PID (C:\Users\Jachs\Downloads\Jurisdiction\target\classes started by zhanchaohan in C:\Users\Jachs\Downloads\Jurisdiction)
-- ::21.467 INFO --- [ main] c.j.j.J.JurisdictionApplication : No active profile set, falling back to default profiles: default
-- ::23.480 INFO --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): (http)
-- ::23.517 INFO --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
-- ::23.517 INFO --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.
-- ::23.531 INFO --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\jdk-8u5-windows-x64\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:/jdk-8u5-windows-x64/bin/../jre/bin/server;D:/jdk-8u5-windows-x64/bin/../jre/bin;D:/jdk-8u5-windows-x64/bin/../jre/lib/amd64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.\;F:\MySql\bin;D:\php-7.0.\php-7.0.;D:\php-7.0.\php-7.0.\ext;F:\TortoiseSVN\bin;F:\VisualSVN-Server-3.5.-x64.msi\VisualSVN Serve\bin;E:\BaiDu\C#\运行Java\ikvm-7.2.4630.5\bin;D:\aspectj1.\bin;D:\cygwin\bin;F:\Git\cmd;E:\BaiDu\JAVA\java\Apache\Maven\gradle-4.6-bin\gradle-4.6\bin;D:\jdk-8u5-windows-x64\bin;E:\BaiDu\JAVA\java\Apache\Maven\apache-maven-3.5.-bin\apache-maven-3.5.\bin;F:\es\zookeeper\bin;F:\es\kafka-eagle-bin-1.2.\kafka-eagle-bin-1.2.\kafka-eagle-web-1.2.-bin\bin;E:\sts-bundle\sts-3.8..RELEASE;;.]
-- ::23.720 INFO --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
-- ::23.720 INFO --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in ms
-- ::23.766 INFO --- [ main] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
-- ::23.772 INFO --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-09-14 16:25:23.773 INFO 5940 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-09-14 16:25:23.773 INFO 5940 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'formContentFilter' to: [/*]
2018-09-14 16:25:23.774 INFO 5940 --- [ main] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-09-14 16:25:23.859 INFO 5940 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2018-09-14 16:25:24.699 INFO 5940 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-09-14 16:25:24.706 INFO 5940 --- [ main] c.j.j.J.JurisdictionApplication : Started JurisdictionApplication in 4.06 seconds (JVM running for 4.971)
2018-09-14 16:25:25.447 INFO 5940 --- [on(2)-127.0.0.1] inMXBeanRegistrar$SpringApplicationAdmin : Application shutdown requested.
2018-09-14 16:25:25.452 INFO 5940 --- [on(2)-127.0.0.1] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'

默认打印采用的是SpringBootBanner代码如下,可以自己改造

/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ package org.springframework.boot; import java.io.PrintStream; import org.springframework.boot.ansi.AnsiColor;
import org.springframework.boot.ansi.AnsiOutput;
import org.springframework.boot.ansi.AnsiStyle;
import org.springframework.core.env.Environment; /**
* Default Banner implementation which writes the 'Spring' banner.
*
* @author Phillip Webb
*/
class SpringBootBanner implements Banner { private static final String[] BANNER = { "",
" . ____ _ __ _ _",
" /\\\\ / ___'_ __ _ _(_)_ __ __ _ \\ \\ \\ \\",
"( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\",
" \\\\/ ___)| |_)| | | | | || (_| | ) ) ) )",
" ' |____| .__|_| |_|_| |_\\__, | / / / /",
" =========|_|==============|___/=/_/_/_/" }; private static final String SPRING_BOOT = " :: Spring Boot :: "; private static final int STRAP_LINE_SIZE = ; @Override
public void printBanner(Environment environment, Class<?> sourceClass,
PrintStream printStream) {
for (String line : BANNER) {
printStream.println(line);
}
String version = SpringBootVersion.getVersion();
version = (version != null) ? " (v" + version + ")" : "";
StringBuilder padding = new StringBuilder();
while (padding.length() < STRAP_LINE_SIZE
- (version.length() + SPRING_BOOT.length())) {
padding.append(" ");
} printStream.println(AnsiOutput.toString(AnsiColor.GREEN, SPRING_BOOT,
AnsiColor.DEFAULT, padding.toString(), AnsiStyle.FAINT, version));
printStream.println();
} }

不想显示初始化Banner时。

application.setBannerMode(Mode.OFF);
Mode说明

该枚举三个CONSOLE打印到控制台,LOG打印到log日志,OFF不打印。

Spring-Boot Banner的更多相关文章

  1. 如何定制 Spring Boot 的 Banner?

    相信用过 Spring Boot 的朋友们一定在启动日志中见过类似如下的内容,比如在启动 Spring Boot 时,控制台默认会打印 Spring Boot Logo 以及版本信息,这是 Sprin ...

  2. Spring Boot Reference Guide

    Spring Boot Reference Guide Authors Phillip Webb, Dave Syer, Josh Long, Stéphane Nicoll, Rob Winch,  ...

  3. Spring boot Sample 002之spring-boot-banner

    一.环境 1.1.Idea 2020.1 1.2.JDK 1.8 二.目的 学习Spring Boot Banner自定义的操作   三.步骤 3.1.点击File -> New Project ...

  4. Spring Boot 2.0(二):Spring Boot 2.0尝鲜-动态 Banner

    Spring Boot 2.0 提供了很多新特性,其中就有一个小彩蛋:动态 Banner,今天我们就先拿这个来尝尝鲜. 配置依赖 使用 Spring Boot 2.0 首先需要将项目依赖包替换为刚刚发 ...

  5. Spring Boot自定义Banner

    在2016年的最后一天,借用Spring Boot的Banner向各位程序猿同仁们问候一声:Happy New Year. 接下来我们就来介绍一下这个轻松愉快的自定义banner功能.实现的方式非常简 ...

  6. (转)Spring Boot 2 (二):Spring Boot 2 尝鲜-动态 Banner

    http://www.ityouknow.com/springboot/2018/03/03/spring-boot-banner.html Spring Boot 2.0 提供了很多新特性,其中就有 ...

  7. Spring boot自定义启动字符画(banner)

    spring boot项目启动时会打印spring boot的ANSI字符画,可以进行自定义. 如何自定义 实现方式非常简单,我们只需要在Spring Boot工程的/src/main/resourc ...

  8. Spring Boot 2.0尝鲜-动态 Banner

    配置依赖 使用 Spring Boot 2.0 首先需要将项目依赖包替换为刚刚发布的 2.0 RELEASE,现在网站https://start.spring.io/也将 Spring Boot 2. ...

  9. Spring Boot笔记之自定义启动banner

    控制banner内容 Spring Boot启动的时候默认的banner是spring的字样,看多了觉得挺单调的,Spring Boot为我们提供了自定义banner的功能. 自定义banner只需要 ...

  10. Spring Boot 2 (二):Spring Boot 2 动态 Banner

    Spring Boot 2 (二):Spring Boot 2 动态 Banner Spring Boot 2.0 提供了很多新特性,其中就有一个小彩蛋:动态 Banner. 一.配置依赖 使用 Sp ...

随机推荐

  1. 【SDOI2017】遗忘的集合

    题目描述 好神仙啊,我还真的以为这是个构造题,结果是有唯一解的. 设答案为多项式\(a,a_i\in\{0,1\}\). 则: \[ f(x)=\Pi (\frac{1}{1-x^i})^{a_i} ...

  2. js如何获取跨域iframe 里面content

    每天学习一点点 编程PDF电子书.视频教程免费下载:http://www.shitanlife.com/code 其中src可能存在跨域. 现有的获取方式   var test = document. ...

  3. 吴恩达课后作业学习2-week1-2正则化

    参考:https://blog.csdn.net/u013733326/article/details/79847918 希望大家直接到上面的网址去查看代码,下面是本人的笔记 4.正则化 1)加载数据 ...

  4. # 20175329 2018-2019-2 《Java程序设计》第二周学习总结

    # 学号 2018-2019-3<Java程序设计>第三周学习总结 ## 教材学习内容总结 第二三章与我们所学习的C语言有很多的相似点,在这里我想主要就以我所学习的效果来讨论一下JAVA与 ...

  5. [BZOJ 3709] Bohater

    Description 在一款电脑游戏中,你需要打败n只怪物(从1到n编号).为了打败第i只怪物,你需要消耗d[i]点生命值,但怪物死后会掉落血药,使你恢复a[i]点生命值.任何时候你的生命值都不能降 ...

  6. 隐写工具Hydan的安装使用方法

    Hydan是可以在32位ELF二进制文件里隐藏信息的工具,主要原理是利用了i386指令中的冗余信息. 官网地址:http://www.crazyboy.com/hydan/ 但这个工具最后更新好像是在 ...

  7. 基于webpack+react+antd 项目构建

    工欲善其事必先利其器,学习React也是如此. 下面分享一篇基于webpack+react+antd 项目构建的好文章, https://blog.hduzplus.xyz/articles/2017 ...

  8. 如何利用snmp协议发现大型复杂环境的网络拓扑

    参考文献:http://blog.51cto.com/13769225/2121431 获取指标参考下图: 1.取接口描述(指定VLAN号) 命令:snmpwalk -v 2c -c Cvicse12 ...

  9. 剑指Offer-- 二叉搜索树的后序遍历序列判断

    版本1:C++ class Solution { public: bool VerifySquenceOfBST(vector<int> sequence) { ) return fals ...

  10. BZOJ1969 航线规划

    给定一个无向图,每次删除一条边,求每次有多少关键边.一条边是关键边,当且仅当从1到n的所有路径都包含这条边.所有时刻图都联通. 考虑倒着做.相当于给一棵树,每次加一条边,这样树上这条边的两个端点间的路 ...