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的图标: . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\_ ...
随机推荐
- datagrid 文本溢出时候 鼠标经过出现提示信息tooltip
1只有文本溢出的单元格鼠标经过才显示提示信息 $('.datagrid-cell').mouseover(function () { if (this.offsetWidth < this.sc ...
- Cookies and Custom Protocols
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/URLLoadingSystem/Cookiesa ...
- java 的枚举变量只能使用枚举常量来初始化--带有关联数据的枚举
public enum ResultEnum { SUCCESS("200","成功"), FAILURE("500","发生异常 ...
- You Can Customize Synthesized Instance Variable Names @property
As mentioned earlier, the default behavior for a writeable property is to use an instance variable c ...
- .ckpt文件与.pb文件
.ckpt文件是旧版本的输出saver.save(sess),相当于现在的.ckpt-data checkpoint文件仅用于告知某些TF函数,这是最新的检查点文件. .ckpt-meta 包含元图, ...
- Hibernate的批量查询——Criteria查询所有、条件、分页、统计(聚合函数)、排序
1.查询所有的学生信息: public static void testSel() { Session session = HibernateUtils.openSession(); Transact ...
- 如何在你的springboot(cloud)项目中引入我的github上的jar仓库呢?
1. 将此标签内容放到pom.xml仅次于project标签下 <repositories> <repository> <id>github</id> ...
- 13--网页,网站,微信公众号基础入门(PHP获取网页的get请求)
https://www.cnblogs.com/yangfengwu/p/11148976.html 大家在访问网页的时候有没有注意一件事情 现在咱来看这种哈 现在咱做个功能哈,类似于这样 长话短说 ...
- Sublime Text 3安装Package Control并安装Processing插件
由于PDE编辑界面对中文的支撑太差,于是想换到ST3来编辑代码,结果导致了噩梦的开始. 首先,找不到“Package Control”!!! 这还怎么玩~ 于是打开http://packagecont ...
- python3-django+uwsgi+supervisor+nginx跳坑指南(记录)
首先运行django项目:在项目目录内: python manage.py runserver 0.0.0.0:8000 外部服务器访问:http://www.xxx.com:8000/ 可以正常运行 ...