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即可,非常方便.但是由此而来的问题是万一 ...
随机推荐
- 【总结整理】WebGIS学习-thinkGIS(地理常识):
##地图知识 ###地图定义 地图是按照一定的法则,有选择地以二维或多维形式与手段在平面或球面上表示地球(或其它星球)若干现象的图形或图像,它具有严格的数学基础.符号系统.文字注记,并能用地图概括原则 ...
- 使用Java读取JSON数据
----------------siwuxie095 JSON 官网:http://www.json.org/ 在官网页面的下方,是 JSON ...
- [转]PHP部分常见算法
1. 用户密码六位数,不能大于六位而不能小于六数,数字值正则为[0-9],请用PHP写出有几种可能性,并做暴力破解; function dePassword($pwd) { $tmp = array( ...
- 32-回文字符串(dp)
http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=37 回文字符串 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描 ...
- Qt测试计算时间
博客转载自:https://blog.csdn.net/lg1259156776/article/details/52325508 一.标准C和C++都可用 1. 获取时间用time_t time( ...
- Visual Studio 代码格式化插件(等号自动对齐、注释自动对齐等)
1.下载地址 插件:Code alignment 下载地址 2.介绍 Based on principles borrowed from mathematics and other discipli ...
- [转]Linux安装前配置操作记录
转至:http://m.blog.csdn.net/weixin_35884835/article/details/52385077 1.修改用户的SHELL的限制,修改/etc/security/l ...
- JDBC 配置环境
一.配置JDBC环境:先下载驱动jar包 1.配置classpath环境变量 如(E:\jdbc\mysql-connector-java-5.1.7-bin.jar) 2.数据库URL: 2.1 ...
- Java50道经典习题-程序47 输入数字打印星号
题目:读取7个数(1—50)的整数值,每读取一个值,程序打印出该值个数的*. import java.util.Scanner; public class Prog47{ public static ...
- c# 创建XML文档,解析XML文档
1.静态函数 using System; using System.Collections.Generic; using System.Linq; using System.Text; using S ...