質問編集履歴

1

BatchController.javaを記載し忘れていたので追記しました。

2019/11/22 04:50

投稿

yyskmr
yyskmr

スコア4

test CHANGED
File without changes
test CHANGED
@@ -108,6 +108,60 @@
108
108
 
109
109
  ```
110
110
 
111
+ BatchController.java
112
+
113
+ ```java
114
+
115
+ @Configuration
116
+
117
+ public class BatchController implements ApplicationRunner {
118
+
119
+
120
+
121
+ public BatchController(String profileName) {
122
+
123
+ try {
124
+
125
+ LoggerConfigLoader.loadLogbackConfig(profileName);
126
+
127
+ } catch (ApplicationException e) {
128
+
129
+ }
130
+
131
+ }
132
+
133
+
134
+
135
+ @Profile("test")
136
+
137
+ public static class TestConfig {
138
+
139
+ @Bean
140
+
141
+ @ConditionalOnProperty(value = { "batch.execute" }, havingValue = "BatchController")
142
+
143
+ public BatchController batchController() {
144
+
145
+ return new BatchController("test");
146
+
147
+ }
148
+
149
+ }
150
+
151
+
152
+
153
+ @Override
154
+
155
+ public void run(ApplicationArguments args) throws ApplicationException {
156
+
157
+ // 処理
158
+
159
+ }
160
+
161
+ }
162
+
163
+ ```
164
+
111
165
  DataConfig.java
112
166
 
113
167
  ```java