首页 文章 精选 留言 我的

精选列表

搜索[任务调度器],共10000篇文章
优秀的个人博客,低调大师

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 10s6 actionable tasks: 2 executed, 4 up-to-dateC: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-examplesservicebuildlibsservice.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: default2020-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: HSQL2020-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-examplesservicebuildlibsservice.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: default2020-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: HSQL2020-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 : >>++>15820581949052020-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 : >>++>15820581949772020-02-18 15:36:34.987 INFO 47168 --- [ main] .o.b.s.JobCompletionNotificationListener : !!! JOB FINISHED! Time to verify the results2020-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 将会执行你指定的作业。

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册