博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring Boot扩展启动行为-改变启动Banner
阅读量:2079 次
发布时间:2019-04-29

本文共 1776 字,大约阅读时间需要 5 分钟。

跟杨春娟学SpringBoot笔记:Spring Boot扩展启动行为-改变启动Banner

完成:第一遍

1.如何改变启动Banner?

可以使用文件的方式来设置Banner

可以从网站拷贝以ASCII码来展示Banner

第一种方式:在SpringBootDemoProjectApplication 通过setBanner()来设置Banner

src/main/resources下有个banner.txt

package com.springboot.demo.SpringBootDemoProject;import org.springframework.boot.Banner.Mode;import org.springframework.boot.ResourceBanner;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.boot.context.properties.EnableConfigurationProperties;import org.springframework.context.annotation.PropertySource;import org.springframework.core.io.ClassPathResource;import com.springboot.demo.SpringBootDemoProject.configuration.AWSConfigBean;import com.springboot.demo.SpringBootDemoProject.configuration.RandomConfigBean;@SpringBootApplication@PropertySource("classpath:config.properties")@EnableConfigurationProperties({
AWSConfigBean.class, RandomConfigBean.class})public class SpringBootDemoProjectApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootDemoProjectApplication.class, args); //SpringApplication springApplication = new SpringApplication(SpringBootDemoProjectApplication.class); //关闭启动Banner //springApplication.setBannerMode(Mode.OFF); //设置启动banner /* * springApplication.setBanner(new ResourceBanner(new * ClassPathResource("banner.txt"))); * springApplication.setBannerMode(Mode.CONSOLE); * * springApplication.run(args); */ }}

第二种方式:在ApplicationContext.properties中

设置Banner

spring.banner.charset=UTF-8spring.banner.location=classpath:banner.txtspring.banner.image.location=classpath:banner.jpgspring.banner.image.width=76spring.banner.image.invert=false

关闭Banner

spring.main.banner-mode=OFF

转载地址:http://irzqf.baihongyu.com/

你可能感兴趣的文章
Git常用命令速查手册
查看>>
Redis运维利器 -- RedisManager
查看>>
分布式之REDIS复习精讲
查看>>
分布式之数据库和缓存双写一致性方案解析
查看>>
Redis集群
查看>>
Oracle 查看和扩展表空间
查看>>
记一次线上Java程序导致服务器CPU占用率过高的问题排除过程
查看>>
Java 内存溢出(java.lang.OutOfMemoryError)的常见情况和处理方式总结
查看>>
从cpu和内存来理解为什么数组比链表查询快
查看>>
CentOS7下使用YUM安装MySQL5.6
查看>>
JVM内存空间
查看>>
Docker 守护进程+远程连接+安全访问+启动冲突解决办法 (完整收藏版)
查看>>
从零写分布式RPC框架 系列 2.0 (4)使用BeanPostProcessor实现自定义@RpcReference注解注入
查看>>
Java 设计模式 轻读汇总版
查看>>
Paxos学习笔记及图解
查看>>
深入解析Spring使用枚举接收参数和返回值机制并提供自定义最佳实践
查看>>
数据序列化框架——Kryo
查看>>
布隆过滤器(BloomFilter)——应用(三)
查看>>
MPP架构数据库优化总结——华为LibrA(MPPDB、GuassDB)与GreenPlum
查看>>
Spark代码可读性与性能优化——示例七(构建聚合器,以用于复杂聚合)
查看>>