質問編集履歴
4
test
CHANGED
File without changes
|
test
CHANGED
@@ -339,3 +339,11 @@
|
|
339
339
|
|
340
340
|
|
341
341
|
Consider defining a bean of type 'org.springframework.batch.support.transaction.ResourcelessTransactionManager' in your configuration.
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
追記
|
346
|
+
|
347
|
+
BatchSchedulerクラスの@configurationを除去するとエラーはなくなりました。
|
348
|
+
|
349
|
+
しかし一度実行しただけで終了されます。方法が間違っているのでしょうか?
|
3
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -229,3 +229,113 @@
|
|
229
229
|
|
230
230
|
|
231
231
|
```
|
232
|
+
|
233
|
+
追記
|
234
|
+
|
235
|
+
以下を参考にバッチを作り直しました。
|
236
|
+
|
237
|
+
http://blogs.innovationm.com/job-scheduling-with-spring-batch/
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
```java
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
246
|
+
|
247
|
+
import org.springframework.batch.core.repository.JobRepository;
|
248
|
+
|
249
|
+
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
|
250
|
+
|
251
|
+
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
|
252
|
+
|
253
|
+
import org.springframework.context.annotation.Bean;
|
254
|
+
|
255
|
+
import org.springframework.context.annotation.Configuration;
|
256
|
+
|
257
|
+
import org.springframework.scheduling.annotation.EnableScheduling;
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
@Configuration
|
262
|
+
|
263
|
+
@EnableScheduling
|
264
|
+
|
265
|
+
public class BatchScheduler {
|
266
|
+
|
267
|
+
@Bean
|
268
|
+
|
269
|
+
public ResourcelessTransactionManager transactionManager() {
|
270
|
+
|
271
|
+
return new ResourcelessTransactionManager();
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
@Bean
|
278
|
+
|
279
|
+
public MapJobRepositoryFactoryBean mapJobRepositoryFactoryBean(ResourcelessTransactionManager resourcelessTransactionManager) throws Exception {
|
280
|
+
|
281
|
+
MapJobRepositoryFactoryBean factoryBean = new MapJobRepositoryFactoryBean(resourcelessTransactionManager);
|
282
|
+
|
283
|
+
factoryBean.afterPropertiesSet();
|
284
|
+
|
285
|
+
return factoryBean;
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
@Bean
|
292
|
+
|
293
|
+
public JobRepository jobRepository(MapJobRepositoryFactoryBean factoryBean) throws Exception{
|
294
|
+
|
295
|
+
return (JobRepository) factoryBean.getObject();
|
296
|
+
|
297
|
+
}
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
@Bean
|
302
|
+
|
303
|
+
public SimpleJobLauncher jobLauncher(JobRepository jobRepository) {
|
304
|
+
|
305
|
+
SimpleJobLauncher launcher = new SimpleJobLauncher();
|
306
|
+
|
307
|
+
launcher.setJobRepository(jobRepository);
|
308
|
+
|
309
|
+
return launcher;
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
```
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
すると以下のエラーが発生します。何か設定が必要なのでしょうか?
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
Description:
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
Parameter 0 of method mapJobRepositoryFactoryBean in position.BatchScheduler required a bean of type 'org.springframework.batch.support.transaction.ResourcelessTransactionManager' that could not be found.
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
Action:
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
Consider defining a bean of type 'org.springframework.batch.support.transaction.ResourcelessTransactionManager' in your configuration.
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,6 +6,12 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
+
追記
|
10
|
+
|
11
|
+
スケジューリングとは1分間に一回など複数回実行することです。
|
12
|
+
|
13
|
+
|
14
|
+
|
9
15
|
```java
|
10
16
|
|
11
17
|
package com.michaelcgood;
|