wy před 1 rokem
rodič
revize
7416f346c0

+ 0 - 17
SpringBatchServiceClient/src/main/java/com/zswl/cloud/springBatch/cline/enhance/EnhanceJobBuilderFactory.java

@@ -1,17 +0,0 @@
-package com.zswl.cloud.springBatch.cline.enhance;
-
-import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.cloud.sleuth.instrument.batch.TraceJobBuilderFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * @author wy
- */
-@Component
-public class EnhanceJobBuilderFactory extends TraceJobBuilderFactory {
-
-    public EnhanceJobBuilderFactory(BeanFactory beanFactory, JobBuilderFactory delegate) {
-        super(beanFactory, delegate);
-    }
-}

+ 0 - 17
SpringBatchServiceClient/src/main/java/com/zswl/cloud/springBatch/cline/enhance/EnhanceStepBuilderFactory.java

@@ -1,17 +0,0 @@
-package com.zswl.cloud.springBatch.cline.enhance;
-
-import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.cloud.sleuth.instrument.batch.TraceStepBuilderFactory;
-import org.springframework.stereotype.Component;
-
-/**
- * @author wy
- */
-@Component
-public class EnhanceStepBuilderFactory extends TraceStepBuilderFactory {
-
-    public EnhanceStepBuilderFactory(BeanFactory beanFactory, StepBuilderFactory delegate) {
-        super(beanFactory, delegate);
-    }
-}

+ 2 - 2
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/config/ChannelOrderBatchConfig.java

@@ -1,8 +1,8 @@
 package com.zswl.cloud.springBtach.server.core.config;
 
-import com.zswl.cloud.springBatch.cline.enhance.EnhanceStepBuilderFactory;
 import org.springframework.batch.core.Step;
 import org.springframework.batch.core.StepContribution;
+import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
 import org.springframework.batch.core.scope.context.ChunkContext;
 import org.springframework.batch.core.step.tasklet.Tasklet;
 import org.springframework.batch.repeat.RepeatStatus;
@@ -18,7 +18,7 @@ import javax.annotation.Resource;
 public class ChannelOrderBatchConfig {
 
     @Resource
-    private EnhanceStepBuilderFactory stepBuilderFactory;
+    private StepBuilderFactory stepBuilderFactory;
 
     @Bean
     public Tasklet channelOrderTaskletA(){

+ 2 - 2
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/config/OrderBatchConfig.java

@@ -1,8 +1,8 @@
 package com.zswl.cloud.springBtach.server.core.config;
 
-import com.zswl.cloud.springBatch.cline.enhance.EnhanceStepBuilderFactory;
 import org.springframework.batch.core.Step;
 import org.springframework.batch.core.StepContribution;
+import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
 import org.springframework.batch.core.scope.context.ChunkContext;
 import org.springframework.batch.core.step.tasklet.Tasklet;
 import org.springframework.batch.repeat.RepeatStatus;
@@ -18,7 +18,7 @@ import javax.annotation.Resource;
 public class OrderBatchConfig {
 
     @Resource
-    private EnhanceStepBuilderFactory stepBuilderFactory;
+    private StepBuilderFactory stepBuilderFactory;
 
     @Bean
     public Tasklet orderTaskletA(){

+ 4 - 2
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/config/SpringBatchConfig.java

@@ -1,8 +1,8 @@
 package com.zswl.cloud.springBtach.server.core.config;
 
-import com.zswl.cloud.springBatch.cline.enhance.EnhanceJobBuilderFactory;
 import org.springframework.batch.core.Job;
 import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
+import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
 import org.springframework.batch.core.launch.support.RunIdIncrementer;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -17,7 +17,7 @@ import javax.annotation.Resource;
 public class SpringBatchConfig {
 
     @Resource
-    private EnhanceJobBuilderFactory jobBuilderFactory;
+    private JobBuilderFactory jobBuilderFactory;
 
     @Resource
     private OrderBatchConfig orderBatchConfig;
@@ -47,4 +47,6 @@ public class SpringBatchConfig {
                 .build();
     }
 
+
+
 }

+ 2 - 14
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/controller/TestSpringBatch.java

@@ -1,15 +1,14 @@
 package com.zswl.cloud.springBtach.server.core.controller;
 
-import com.zswl.cloud.springBatch.cline.enhance.EnhanceStepBuilderFactory;
 import com.zswl.cloud.springBtach.server.core.service.JobService;
 import org.springframework.batch.core.ExitStatus;
 import org.springframework.batch.core.Step;
 import org.springframework.batch.core.StepContribution;
+import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
 import org.springframework.batch.core.job.SimpleJob;
 import org.springframework.batch.core.scope.context.ChunkContext;
 import org.springframework.batch.core.step.tasklet.Tasklet;
 import org.springframework.batch.repeat.RepeatStatus;
-import org.springframework.context.annotation.Bean;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -26,7 +25,7 @@ public class TestSpringBatch {
     private JobService jobService;
 
     @Resource
-    private EnhanceStepBuilderFactory stepBuilderFactory;
+    private StepBuilderFactory stepBuilderFactory;
 
     @GetMapping("/job/order")
     public ExitStatus startJob1(String name) throws Exception {
@@ -38,17 +37,6 @@ public class TestSpringBatch {
         return jobService.channelOrderBatch(name);
     }
 
-    @Bean
-    public Tasklet tasklet() {
-        return new Tasklet() {
-            @Override
-            public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
-                System.out.println("----------------taskletA---------------" + chunkContext.getStepContext().getJobParameters().get("name"));
-                return RepeatStatus.FINISHED;
-            }
-        };
-    }
-
     public Step stepA(){
         //tasklet 执行step逻辑, 类似 Thread()--->可以执行runable接口
         return stepBuilderFactory.get("stepA")