Spring Batch 在默认情况下的任务执行
在默认情况,如果你对 Spring Batch 不进行配置的话。
Spring Batch 将会对所有存在的作业(Job)进行执行。
考察项目:https://github.com/cwiki-us-spring/cwiki-us-spring-batch-examples 你可以 Check out 到本地后运行:
gradlew :service:bootJar
将会对项目进行编译,程序将会输出:
C:WorkDirRepositorySpringcwiki-us-spring-guidescwiki-us-spring-batch-examples>gradlew :service:bootJar
Configure project :
You are using one or more deprecated Asciidoctor Gradle plugin features. To help with migration run with --warning-mode=all.
Repository https://jcenter.bintray.com/ replaced by https://maven.ossez.com/repository/internal.
BUILD SUCCESSFUL in 10s
6 actionable tasks: 2 executed, 4 up-to-date
C:WorkDirRepositorySpringcwiki-us-spring-guidescwiki-us-spring-batch-examples>
然后你可以运行
java -jar service/build/libs/service.jar
你会发现没有作业被执行
程序输出如下:
C:WorkDirRepositorySpringcwiki-us-spring-guidescwiki-us-spring-batch-examples>java -jar service/build/libs/service.jar
. _
/\ / ' _(_) _ \
( ( )__ | ' | '_| | '_ / _` | \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2020-02-18 15:32:38.016 INFO 28560 --- [ main] com.ossez.batch.service.Application : Starting Application on USWTWNB47141 with PID 28560 (C:WorkDirRepositorySpringcwiki-us-spring-guidescwiki-us-spring-batch-exam
plesservicebuildlibsservice.jar started by yhu in C:WorkDirRepositorySpringcwiki-us-spring-guidescwiki-us-spring-batch-examples)
2020-02-18 15:32:38.023 INFO 28560 --- [ main] com.ossez.batch.service.Application : No active profile set, falling back to default profiles: default
2020-02-18 15:32:40.344 INFO 28560 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-02-18 15:32:40.353 WARN 28560 --- [ main] com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=org.hsqldb.jdbcDriver was not found, trying direct instantiation.
2020-02-18 15:32:40.854 INFO 28560 --- [ main] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (feature not supported)
2020-02-18 15:32:40.866 INFO 28560 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-02-18 15:32:42.711 INFO 28560 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: HSQL
2020-02-18 15:32:43.137 INFO 28560 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : No TaskExecutor has been set, defaulting to synchronous executor.
2020-02-18 15:32:44.502 INFO 28560 --- [ main] com.ossez.batch.service.Application : Started Application in 7.373 seconds (JVM running for 8.576)
2020-02-18 15:32:44.529 INFO 28560 --- [ Thread-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-02-18 15:32:44.537 INFO 28560 --- [ Thread-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
C:WorkDirRepositorySpringcwiki-us-spring-guidescwiki-us-spring-batch-examples>
如果你希望有作业被默认执行的话,你需要修改你检出项目的 application.properties 文件
将参数
spring.batch.job.enabled=false
修改为 true
然后重新编译然后执行,你将会发现所有作业将会被默认执行了。
C:WorkDirRepositorySpringcwiki-us-spring-guidescwiki-us-spring-batch-examples>java -jar service/build/libs/service.jar
. _
/\ / ' _(_) _ \
( ( )__ | ' | '_| | '_ / _` | \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2020-02-18 15:36:29.621 INFO 47168 --- [ main] com.ossez.batch.service.Application : Starting Application on USWTWNB47141 with PID 47168 (C:WorkDirRepositorySpringcwiki-us-spring-guidescwiki-us-spring-batch-exam
plesservicebuildlibsservice.jar started by yhu in C:WorkDirRepositorySpringcwiki-us-spring-guidescwiki-us-spring-batch-examples)
2020-02-18 15:36:29.625 INFO 47168 --- [ main] com.ossez.batch.service.Application : No active profile set, falling back to default profiles: default
2020-02-18 15:36:31.611 INFO 47168 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-02-18 15:36:31.620 WARN 47168 --- [ main] com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=org.hsqldb.jdbcDriver was not found, trying direct instantiation.
2020-02-18 15:36:31.978 INFO 47168 --- [ main] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (feature not supported)
2020-02-18 15:36:31.984 INFO 47168 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-02-18 15:36:33.087 INFO 47168 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: HSQL
2020-02-18 15:36:33.493 INFO 47168 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : No TaskExecutor has been set, defaulting to synchronous executor.
2020-02-18 15:36:34.706 INFO 47168 --- [ main] com.ossez.batch.service.Application : Started Application in 5.952 seconds (JVM running for 7.127)
2020-02-18 15:36:34.709 INFO 47168 --- [ main] o.s.b.a.b.JobLauncherCommandLineRunner : Running default command line with: []
2020-02-18 15:36:34.851 INFO 47168 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=cloudClean]] launched with the following parameters: [{run.id=1}]
2020-02-18 15:36:34.884 INFO 47168 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [readFilesStep]
2020-02-18 15:36:34.957 INFO 47168 --- [ main] c.o.batch.service.tasklet.FileTasklet : >>++>1582058194905
2020-02-18 15:36:34.974 INFO 47168 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [deleteFilesStep]
2020-02-18 15:36:34.977 INFO 47168 --- [ main] c.o.batch.service.tasklet.FileTasklet : >>++>1582058194977
2020-02-18 15:36:34.987 INFO 47168 --- [ main] .o.b.s.JobCompletionNotificationListener : !!! JOB FINISHED! Time to verify the results
2020-02-18 15:36:34.990 INFO 47168 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=cloudClean]] completed with the following parameters: [{run.id=1}] and the following status: [COMPLETED]
2020-02-18 15:36:35.023 INFO 47168 --- [ Thread-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-02-18 15:36:35.030 INFO 47168 --- [ Thread-2] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
C:WorkDirRepositorySpringcwiki-us-spring-guidescwiki-us-spring-batch-examples>
请注意,在这里我们配置了
spring.batch.job.names=cloudClean
所以默认将会执行 cloudClean 作业。
或者你可以执行运行命令:
java -jar service/build/libs/service.jar --spring.batch.job.enabled=true --spring.batch.job.names=cloudClean
将会执行你指定的作业。
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
三个你必须要记住的Pyinstaller打包命令——利用Python实现打包exe
/1 前言/ 嘿,各位小伙伴,晚上好呀,我相信各位小伙伴都是python的爱好者。也许我们不一定是专业的程序员,但是我们仍然可以通过代码提高我们的效率,尽量少加班,多陪陪媳妇。再不行,让代码替我们干着重复的工作,我们有节省出来的时间打游戏不好嘛,是吧,哈哈哈。 但是呢,我们开发的脚本一般都会用到一些第三方包,可能别人也需要用到我们的脚本,如果我们将我们的xx.py文件发给他,他是不能直接用的,他还需要安装python解释器,甚至还要安装我们用的那些第三方包,是不是有点小麻烦?但是我们都知道,PC是可以直接运行exe文件的,这就为我们提供了一个便捷的方式。所以,从看了这个教程以后,这都将成为过去式,打成exe之后,分享即可用。 PS: 如果打包为exe的话,版本尽量选择python3.6+32位版本,因为win64位系统向下兼容32位程序,但是如果不考虑32位系统的话无所谓,直接python64位版本直接打包就可以,只是只能在win64位系统上跑。 /2 安装pyinstaller/ 首先安装pyinstaller,使用安装命令:pip3 install pyinstaller,如下图所...
- 下一篇
基于 Google-S2 的地理相册服务实现及应用
马蜂窝技术原创内容,更多干货请关注公众号:mfwtech 随着智能手机存储容量的增大,以及相册备份技术的普及,我们可以随时随地用手机影像记录生活,在手机中存储几千张甚至上万张照片已经是很常见的事情。但另一方面,当我们想从这么多张照片中去找到一张,也是一件麻烦事。 马蜂窝作为旅行玩乐平台,希望实现「会玩的人」与「好玩的事」之间的连接。众多旅行爱好者在这里记录和分享他们的旅行记忆,使马蜂窝在旅游 UGC 领域累积了大量内容。因此,不断优化用户在发布内容时的体验是我们一直努力的主向。 用照片、视频记录旅行是最直接的方式。本文将介绍马蜂窝如何通过 App 地理相册空间索引的应用,为用户提供直观、好用的图片分享服务。 Part.1 应用场景和需求 要想让用户快速地找到想要分享的照片/视频,我们需要一个有效且合理的筛选手段,对用户的相册进行聚合、排序,提升用户依托相册去分享和记录生活时易用性和便捷性。 首先要确定聚合排序的筛选维度。照片的地理位置就是最直观的分类维度;同时,记录最近发生的事情符合用户的发布行为习惯。因此我们方案要满足的需求是: 根据目的地和时间,对用户相册进行聚合、排序; 基于某个...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Red5直播服务器,属于Java语言的直播服务器
- CentOS6,CentOS7官方镜像安装Oracle11G
- CentOS关闭SELinux安全模块
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池
- CentOS7编译安装Gcc9.2.0,解决mysql等软件编译问题
- SpringBoot2整合Thymeleaf,官方推荐html解决方案
- CentOS7安装Docker,走上虚拟化容器引擎之路
- CentOS7,CentOS8安装Elasticsearch6.8.6
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- CentOS7设置SWAP分区,小内存服务器的救世主