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

質問編集履歴

1

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

2019/11/22 04:50

投稿

yyskmr
yyskmr

スコア4

title CHANGED
File without changes
body CHANGED
@@ -53,6 +53,33 @@
53
53
  }
54
54
  }
55
55
  ```
56
+ BatchController.java
57
+ ```java
58
+ @Configuration
59
+ public class BatchController implements ApplicationRunner {
60
+
61
+ public BatchController(String profileName) {
62
+ try {
63
+ LoggerConfigLoader.loadLogbackConfig(profileName);
64
+ } catch (ApplicationException e) {
65
+ }
66
+ }
67
+
68
+ @Profile("test")
69
+ public static class TestConfig {
70
+ @Bean
71
+ @ConditionalOnProperty(value = { "batch.execute" }, havingValue = "BatchController")
72
+ public BatchController batchController() {
73
+ return new BatchController("test");
74
+ }
75
+ }
76
+
77
+ @Override
78
+ public void run(ApplicationArguments args) throws ApplicationException {
79
+ // 処理
80
+ }
81
+ }
82
+ ```
56
83
  DataConfig.java
57
84
  ```java
58
85
  @Configuration