@@ -98,9 +98,11 @@ void incrementExistingExecution() {
98
98
@ Test
99
99
void retryFailedExecution () {
100
100
this .contextRunner .run ((context ) -> {
101
+ PlatformTransactionManager transactionManager = context .getBean (PlatformTransactionManager .class );
101
102
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext (context );
102
103
Job job = jobLauncherContext .jobBuilder ()
103
- .start (jobLauncherContext .stepBuilder ().tasklet (throwingTasklet ()).build ())
104
+ .start (jobLauncherContext .stepBuilder ().tasklet (throwingTasklet ())
105
+ .transactionManager (transactionManager ).build ())
104
106
.incrementer (new RunIdIncrementer ()).build ();
105
107
jobLauncherContext .runner .execute (job , new JobParameters ());
106
108
jobLauncherContext .runner .execute (job , new JobParametersBuilder ().addLong ("run.id" , 1L ).toJobParameters ());
@@ -111,9 +113,10 @@ void retryFailedExecution() {
111
113
@ Test
112
114
void runDifferentInstances () {
113
115
this .contextRunner .run ((context ) -> {
116
+ PlatformTransactionManager transactionManager = context .getBean (PlatformTransactionManager .class );
114
117
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext (context );
115
- Job job = jobLauncherContext .jobBuilder ()
116
- .start ( jobLauncherContext . stepBuilder (). tasklet ( throwingTasklet () ).build ()).build ();
118
+ Job job = jobLauncherContext .jobBuilder (). start ( jobLauncherContext . stepBuilder (). tasklet ( throwingTasklet ())
119
+ .transactionManager ( transactionManager ).build ()).build ();
117
120
// start a job instance
118
121
JobParameters jobParameters = new JobParametersBuilder ().addString ("name" , "foo" ).toJobParameters ();
119
122
jobLauncherContext .runner .execute (job , jobParameters );
@@ -128,9 +131,11 @@ void runDifferentInstances() {
128
131
@ Test
129
132
void retryFailedExecutionOnNonRestartableJob () {
130
133
this .contextRunner .run ((context ) -> {
134
+ PlatformTransactionManager transactionManager = context .getBean (PlatformTransactionManager .class );
131
135
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext (context );
132
136
Job job = jobLauncherContext .jobBuilder ().preventRestart ()
133
- .start (jobLauncherContext .stepBuilder ().tasklet (throwingTasklet ()).build ())
137
+ .start (jobLauncherContext .stepBuilder ().tasklet (throwingTasklet ())
138
+ .transactionManager (transactionManager ).build ())
134
139
.incrementer (new RunIdIncrementer ()).build ();
135
140
jobLauncherContext .runner .execute (job , new JobParameters ());
136
141
jobLauncherContext .runner .execute (job , new JobParameters ());
@@ -149,9 +154,11 @@ void retryFailedExecutionOnNonRestartableJob() {
149
154
@ Test
150
155
void retryFailedExecutionWithNonIdentifyingParameters () {
151
156
this .contextRunner .run ((context ) -> {
157
+ PlatformTransactionManager transactionManager = context .getBean (PlatformTransactionManager .class );
152
158
JobLauncherApplicationRunnerContext jobLauncherContext = new JobLauncherApplicationRunnerContext (context );
153
159
Job job = jobLauncherContext .jobBuilder ()
154
- .start (jobLauncherContext .stepBuilder ().tasklet (throwingTasklet ()).build ())
160
+ .start (jobLauncherContext .stepBuilder ().tasklet (throwingTasklet ())
161
+ .transactionManager (transactionManager ).build ())
155
162
.incrementer (new RunIdIncrementer ()).build ();
156
163
JobParameters jobParameters = new JobParametersBuilder ().addLong ("id" , 1L , false ).addLong ("foo" , 2L , false )
157
164
.toJobParameters ();
@@ -187,9 +194,11 @@ static class JobLauncherApplicationRunnerContext {
187
194
JobLauncherApplicationRunnerContext (ApplicationContext context ) {
188
195
JobLauncher jobLauncher = context .getBean (JobLauncher .class );
189
196
JobRepository jobRepository = context .getBean (JobRepository .class );
197
+ PlatformTransactionManager transactionManager = context .getBean (PlatformTransactionManager .class );
190
198
this .jobs = new JobBuilderFactory (jobRepository );
191
- this .steps = new StepBuilderFactory (jobRepository , context .getBean (PlatformTransactionManager .class ));
192
- this .step = this .steps .get ("step" ).tasklet ((contribution , chunkContext ) -> null ).build ();
199
+ this .steps = new StepBuilderFactory (jobRepository );
200
+ this .step = this .steps .get ("step" ).tasklet ((contribution , chunkContext ) -> null )
201
+ .transactionManager (transactionManager ).build ();
193
202
this .job = this .jobs .get ("job" ).start (this .step ).build ();
194
203
this .jobExplorer = context .getBean (JobExplorer .class );
195
204
this .runner = new JobLauncherApplicationRunner (jobLauncher , this .jobExplorer , jobRepository );
0 commit comments