Spring Boot启动时调用自己的非web逻辑
作者:zhangjikuan 时间:2022-02-15 11:40:10
在spring Boot中,有些代码是WEB功能,例如API等,但是有些逻辑是非WEB,启动时就要调用并持续运行的,该如何加载自己的非WEB逻辑呢?
SpringBootApplication类实现CommandLineRunner并覆盖run()方法
@SpringBootApplication
public class ZjkApplication implements CommandLineRunner{
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// WEB
SpringApplication.run(ZjkApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
//your logic
System.out.println("into zjk run");
}
}
使用上面方式启动的SPRING BOOT,即可以运行WEB又可以运行自己的逻辑
总结
以上所述是小编给大家介绍的Spring Boot启动时调用自己的非web逻辑网站的支持!
来源:http://blog.csdn.net/zhangjikuan/article/details/76181657
标签:spring,boot启动,调用
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java冒泡排序及优化介绍
2023-11-11 13:05:51
IntelliJ IDEA Project窗口的一些设置详解
2023-11-09 04:54:44
![](https://img.aspxhome.com/file/2023/6/58926_0s.png)
java字符串相似度算法
2023-11-26 12:33:25
C#实现创建标签PDF文件的示例代码
2023-09-15 07:04:58
![](https://img.aspxhome.com/file/2023/7/80117_0s.png)
Java基于ArrayList实现群主发红包功能
2022-04-06 20:34:09
![](https://img.aspxhome.com/file/2023/4/74914_0s.png)
Java设计模式之访问者模式
2023-04-17 20:00:15
![](https://img.aspxhome.com/file/2023/5/60135_0s.png)
Java实现Timer的定时调度函数schedule的四种用法
2022-08-14 04:49:01
SpringBoot 配置文件总结
2021-09-06 13:12:57
![](https://img.aspxhome.com/file/2023/3/59343_0s.webp)
Java判断所给年份是平年还是闰年
2023-10-21 17:48:59
thymeleaf中前后端数据交互方法汇总
2023-07-18 21:15:59
java实现滑动验证解锁
2023-06-02 12:16:36
![](https://img.aspxhome.com/file/2023/4/74894_0s.jpg)
java8 stream多字段排序的实现
2021-07-30 17:47:47
WPF实现动画效果
2023-06-26 17:49:44
![](https://img.aspxhome.com/file/2023/3/83303_0s.jpg)
Spring Security认证提供程序示例详解
2022-11-07 18:06:40
spring boot如何加入mail邮件支持
2021-09-27 15:12:57
flutter TextField换行自适应的实现
2023-06-21 01:21:39
Java编程实现A*算法完整代码
2022-06-18 12:28:57
![](https://img.aspxhome.com/file/2023/1/72591_0s.png)
Java中对list map根据map某个key值进行排序的方法
2023-09-04 17:10:03
Spring如何使用注解的方式创建bean
2022-01-29 03:45:49
详解基于MVC的数据查询模块进行模糊查询
2022-02-13 19:26:49