teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

2018/10/26 03:41

投稿

star0415
star0415

スコア25

title CHANGED
File without changes
body CHANGED
@@ -168,4 +168,8 @@
168
168
 
169
169
  Action:
170
170
 
171
- Consider defining a bean of type 'org.springframework.batch.support.transaction.ResourcelessTransactionManager' in your configuration.
171
+ Consider defining a bean of type 'org.springframework.batch.support.transaction.ResourcelessTransactionManager' in your configuration.
172
+
173
+ 追記
174
+ BatchSchedulerクラスの@configurationを除去するとエラーはなくなりました。
175
+ しかし一度実行しただけで終了されます。方法が間違っているのでしょうか?

3

2018/10/26 03:41

投稿

star0415
star0415

スコア25

title CHANGED
File without changes
body CHANGED
File without changes

2

2018/10/26 01:14

投稿

star0415
star0415

スコア25

title CHANGED
File without changes
body CHANGED
@@ -113,4 +113,59 @@
113
113
  }
114
114
  }
115
115
 
116
- ```
116
+ ```
117
+ 追記
118
+ 以下を参考にバッチを作り直しました。
119
+ http://blogs.innovationm.com/job-scheduling-with-spring-batch/
120
+
121
+ ```java
122
+
123
+ import org.springframework.batch.core.launch.support.SimpleJobLauncher;
124
+ import org.springframework.batch.core.repository.JobRepository;
125
+ import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
126
+ import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
127
+ import org.springframework.context.annotation.Bean;
128
+ import org.springframework.context.annotation.Configuration;
129
+ import org.springframework.scheduling.annotation.EnableScheduling;
130
+
131
+ @Configuration
132
+ @EnableScheduling
133
+ public class BatchScheduler {
134
+ @Bean
135
+ public ResourcelessTransactionManager transactionManager() {
136
+ return new ResourcelessTransactionManager();
137
+ }
138
+
139
+ @Bean
140
+ public MapJobRepositoryFactoryBean mapJobRepositoryFactoryBean(ResourcelessTransactionManager resourcelessTransactionManager) throws Exception {
141
+ MapJobRepositoryFactoryBean factoryBean = new MapJobRepositoryFactoryBean(resourcelessTransactionManager);
142
+ factoryBean.afterPropertiesSet();
143
+ return factoryBean;
144
+ }
145
+
146
+ @Bean
147
+ public JobRepository jobRepository(MapJobRepositoryFactoryBean factoryBean) throws Exception{
148
+ return (JobRepository) factoryBean.getObject();
149
+ }
150
+
151
+ @Bean
152
+ public SimpleJobLauncher jobLauncher(JobRepository jobRepository) {
153
+ SimpleJobLauncher launcher = new SimpleJobLauncher();
154
+ launcher.setJobRepository(jobRepository);
155
+ return launcher;
156
+ }
157
+
158
+ }
159
+
160
+ ```
161
+
162
+ すると以下のエラーが発生します。何か設定が必要なのでしょうか?
163
+
164
+ Description:
165
+
166
+ Parameter 0 of method mapJobRepositoryFactoryBean in position.BatchScheduler required a bean of type 'org.springframework.batch.support.transaction.ResourcelessTransactionManager' that could not be found.
167
+
168
+
169
+ Action:
170
+
171
+ Consider defining a bean of type 'org.springframework.batch.support.transaction.ResourcelessTransactionManager' in your configuration.

1

2018/10/25 23:22

投稿

star0415
star0415

スコア25

title CHANGED
File without changes
body CHANGED
@@ -2,6 +2,9 @@
2
2
  調べても方法がわかりません。
3
3
  詳しい方ご教示願えませんか?
4
4
 
5
+ 追記
6
+ スケジューリングとは1分間に一回など複数回実行することです。
7
+
5
8
  ```java
6
9
  package com.michaelcgood;
7
10