Spring boot启动成功后输出提示
添加logback-spring.xml,将log输出到文件,控制台输出的level改为error因此只会出处banner
src/main/resources/banner.txt的内容为
start...
但是输出完banner后,spring boot并没有启动完毕
因此,我想在Spring boot启动成功后输出提示
有两种方式
1.实现 ApplicationRunnerImpl
eg:
package com.example.demo.configure; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component; @Component
public class ApplicationRunnerImpl implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
System.out.println("application start...");
}
}
2.实现 CommandLineRunnerImpl
eg:
package com.example.demo.configure; import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component; @Component
public class CommandLineRunnerImpl implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
System.out.println("application start...");
}
}
输出:
start...
application running...
注:
执行时机为容器启动完成的时候
run方法中接收的参数类型不一样
如果有多个实现类,并且需要按一定顺序执行,可以在实现类上加上@Order注解。@Order(value=整数值)。SpringBoot会按照@Order中的value值从小到大依次执行
Spring boot启动成功后输出提示的更多相关文章
- spring boot 启动类一定要放置到包的根目录下,也就是和所有包含java文件的包在同一级目录。如果不放置在根目录下,将会提示 no mybatis mapper was found
spring boot 启动类一定要放置到包的根目录下,也就是和所有包含java文件的包在同一级目录.将会将同一目录下的包扫描成bean. 如果不放置在根目录下,将会提示 no mybatis map ...
- Spring Boot 启动原理分析
https://yq.aliyun.com/articles/6056 转 在spring boot里,很吸引人的一个特性是可以直接把应用打包成为一个jar/war,然后这个jar/war是可以直接启 ...
- Spring Boot启动过程(四):Spring Boot内嵌Tomcat启动
之前在Spring Boot启动过程(二)提到过createEmbeddedServletContainer创建了内嵌的Servlet容器,我用的是默认的Tomcat. private void cr ...
- Spring Boot启动过程(七):Connector初始化
Connector实例的创建已经在Spring Boot启动过程(四):Spring Boot内嵌Tomcat启动中提到了: Connector是LifecycleMBeanBase的子类,先是设置L ...
- Spring Boot 启动(一) SpringApplication 分析
Spring Boot 启动(一) SpringApplication 分析 Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.html ...
- springboot项目启动成功后执行一段代码的两种方式
springboot项目启动成功后执行一段代码的两种方式 实现ApplicationRunner接口 package com.lnjecit.lifecycle; import org.springf ...
- spring boot启动原理步骤分析
spring boot最重要的三个文件:1.启动类 2.pom.xml 3.application.yml配置文件 一.启动类->main方法 spring boot启动原理步骤分析 1.spr ...
- Spring Boot 启动事件和监听器,太强大了!
大家都知道,在 Spring 框架中事件和监听无处不在,打通了 Spring 框架的任督二脉,事件和监听也是 Spring 框架必学的核心知识之一. 一般来说,我们很少会使用到应用程序事件,但我们也不 ...
- Spring Boot -- 启动彩蛋
使用Spring Boot启动的jar包总是会显示一个Spring的图标: . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\_ ...
随机推荐
- Linux shell脚本基础学习详细介绍(完整版)二
详细介绍Linux shell脚本基础学习(五) Linux shell脚本基础前面我们在介绍Linux shell脚本的控制流程时,还有一部分内容没讲就是有关here document的内容这里继续 ...
- accept返回的socket的端口号和连接socket一样的!!! socket绑定信息结构
今天与同学争执一个话题:由于socket的accept函数在有客户端连接的时候产生了新的socket用于服务该客户端,那么,这个新的socket到底有没有占用一个新的端口? 讨论完后,才发现,自己虽然 ...
- 用Python 打开程序的两中方法
1.ShellExecute函数 import win32api win32api.ShellExecute(0, 'open', 'notepad.exe', '', '', 0) # 后台执行 w ...
- OpenCV 学习笔记(8)彩色图像RGB通道的分离、合并与显示
https://blog.csdn.net/ZYTTAE/article/details/42234989 由于算法的需要,需要把彩色图像的R.G.B值分离出来,OpenCV中正好有split() 和 ...
- 04_配置交换机Telnet服务(数通华为)
1. 网络拓扑: 2. SW1配置:2.1 配置为Access口,vlan 10:[SW1]vlan 10[SW1-GigabitEthernet0/0/1]port link-type access ...
- Cronicle 基于nodejs 的分布式任务调度工具
Cronicle 是一款不多的分布式任务调度工具,基于nodejs 开发,同时包含看web UI,从官方介绍看到的UI还是 挺不错的,而且功能很丰富,值得试用下 参考资料 http://cronicl ...
- GIT与项目
创建GitHub账号 本地Git仓库和GitHub仓库之间的传输是通过SSH加密的 step1:创建项目的SSH Key ssh-keygen -t rsa -C "your email@e ...
- [Beta]Scrum Meeting#8
github 本次会议项目由PM召开,时间为5月13日晚上10点30分 时长10分钟 任务表格 人员 昨日工作 下一步工作 木鬼 撰写博客整理文档 撰写博客整理文档 swoip 为适应新功能调整布局 ...
- dateTime格式转换
select Convert(varchar(8),GETDATE(),112) Select replace(CONVERT(varchar(8), GETDATE(), 108),':','')
- fastjson在反序列化时,解析对象中的继承,抽象类处理
LimitActionConfig是ActionConfig的子类,RuleConfig的有个属性是ActionConfig,需要反序列化成LimitActionConfig ParserConfig ...