回答編集履歴
1
内容の誤り修正、誤字修正
answer
CHANGED
@@ -25,7 +25,8 @@
|
|
25
25
|
}
|
26
26
|
```
|
27
27
|
|
28
|
-
クラスにバインドしたい場合、
|
28
|
+
クラスにバインドしたい場合、以下の手順で追加できます
|
29
|
+
`org.springframework.boot:spring-boot-configuration-processor` をビルドツールの設定に追加する。
|
29
30
|
SpringBoot の `Application` class に `@ConfigurationPropertiesScan` を付与する。
|
30
31
|
適当に設定ファイルに設定と、SpringBoot のスコープ内のどこかに class を作成する。
|
31
32
|
例としては以下
|
@@ -45,11 +46,11 @@
|
|
45
46
|
@ConstructorBinding
|
46
47
|
@ConfigurationProperties("app.config")
|
47
48
|
public class SampleConfig {
|
48
|
-
private final String
|
49
|
+
private final String csvFile;
|
49
50
|
private final int timeout;
|
50
51
|
|
51
|
-
public SampleConfig(String
|
52
|
+
public SampleConfig(String csvFile, int timeout) {
|
52
|
-
this.
|
53
|
+
this.csvFile= csvFile;
|
53
54
|
this.timeout = timeout;
|
54
55
|
}
|
55
56
|
}
|
@@ -62,7 +63,7 @@
|
|
62
63
|
private final String cfvFilePath;
|
63
64
|
private final int timeout;
|
64
65
|
public ConfigRepositoryImpl(SampleConfig config) {
|
65
|
-
cfvFilePath = config.
|
66
|
+
cfvFilePath = config.getCsvFile();
|
66
67
|
this.timeout = config.getTimeout();
|
67
68
|
}
|
68
69
|
// 以下省略...
|