spring boot 系统启动时运行代码(1)-@PostConstruct
Application.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
AppInitializator.java
import javax.annotation.PostConstruct; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @Slf4j
@Component
public class AppInitializator {
@PostConstruct
private void init() {
log.info("AppInitializator initialization logic ...");
}
}
输出:
2019-01-04 13:31:05.345 INFO 3664 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2019-01-04 13:31:05.399 INFO 3664 --- [ main] com.ebc.AppInitializator : AppInitializator initialization logic ...
2019-01-04 13:31:05.564 INFO 3664 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
spring boot 系统启动时运行代码(1)-@PostConstruct的更多相关文章
- spring boot 启动时运行代码(2)ApplicationListener
项目概览: StepExecutor: @Component @Slf4j public class StepExecutor implements Runnable { @Autowired pri ...
- spring boot 和shiro的代码实战demo
spring boot和shiro的代码实战 首先说明一下,这里不是基础教程,需要有一定的shiro知识,随便百度一下,都能找到很多的博客叫你基础,所以这里我只给出代码. 官方文档:http://sh ...
- Windows: 在系统启动时运行程序、定时计划任务、定时关机
lesca今天介绍一些让系统在启动时,而非登录时,加载用户自定义的应用程序或脚本的方法,推荐度从前到后依次递减. 1. Windows任务计划(task scheduler) 用户可以按以下步骤进行操 ...
- 使用Spring boot整合Hive,在启动Spring boot项目时,报错
使用Spring boot整合Hive,在启动Spring boot项目时,报出异常: java.lang.NoSuchMethodError: org.eclipse.jetty.servlet.S ...
- spring boot启动STS 运行报错 java.lang.NoClassDefFoundError: ch/qos/logback/classic/LoggerContext
spring boot启动STS 运行报错 java.lang.NoClassDefFoundError: ch/qos/logback/classic/LoggerContext 学习了: http ...
- spring boot项目后台运行
spring boot项目后台运行 Spring Boot应用的几种运行方式: (1)运行Spring Boot的应用主类 (2)使用Maven的Spring Boot插件mvn spring-boo ...
- Spring Boot 系统启动任务定义
前言 系统任务:在项目启动阶段要做一些数据初始化操作,这些操作有一个共同的特点,只在项目启动时进行,以后都不再执行. 应用场景:例如配置文件加载,数据库初始化等操作 Spring Boot出现之前 解 ...
- 让你的Spring Boot应用快速运行在Docker上面
前置条件: 1. 服务器(我这边是CentOS7)上已经安装了Docker(安装步骤很简单,可以参考我上一篇博客) 2.服务器上已经安装了Java和Maven 在满足以上条件后,我们就可以开始了: 1 ...
- 使用pm2来保证Spring Boot应用稳定运行
Spring Boot开发web应用就像开发普通的java程序一般简洁,因为其内嵌了web容易,启动的时候只需要一条命令java -jar server.jar即可,非常方便.但是由此而来的问题是万一 ...
随机推荐
- ES6中变量的解析赋值的用途
变量的解构赋值用途很多. (1)交换变量的值 let x = 1; let y = 2; [x, y] = [y, x]; 上面代码交换变量x和y的值,这样的写法不仅简洁,而且易读,语义非常清晰. ( ...
- p4570 [BJWC2011]元素
传送门 分析 对法力值从大到小排序然后对编号跑线性基即可 代码 #include<iostream> #include<cstdio> #include<cstring& ...
- Luogu 2737 [USACO4.1]麦香牛块Beef McNuggets
NOIP2017 D1T1 的结论,两个数$a, b$所不能表示出的最大的数为$a * b - a - b$. 听了好几遍证明我还是不会 注意到本题中给出的数都非常小,所以最大不能表示出的数$\leq ...
- thinkphp目录解析
- Swing窗口Linux下不支持最大化问题
Swing窗口Linux下不支持最大化问题 摘自:https://www.linuxidc.com/Linux/2009-06/20519.htm [日期:2009-06-17] 来源:www.qua ...
- C++ string操作(转载)
1.string类的构造函数 string(const char * s); //用s字符串初始化 string(const string &s);//用string类的s初始化 string ...
- Server.MapPath方法的应用方法
老是忘记Server.MapPath的使用方法了,下面记录一下,以备后用:总注:Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径1.Server.MapPath(&q ...
- 动态绑数据(Repeater控件HeaderTemplate和ItemTemplate)
前几天,Insus.NET有写了<动态绑数据(GridView控件Header和ItemTemplate)>http://www.cnblogs.com/insus/p/3303192.h ...
- 记一次RSA非对称算法的排坑经历
Map<String,Object> encryParam = new HashMap<>(5); encryParam.put("connectorUrl" ...
- UIViewController函数调用顺序
/*********** 0 执行1次而已 ******************/ + (void)load { NSLog(@" 0:%s", __func__); } /*** ...