Spring Bootの@Valueを使って外部ファイルを読み込む方法

#前提
以下のファイルを読み込みます。

```test.csv
apple,banana,orange
Tokyo,Osaka,Kyoto
Baseball,Basketball,Soccer
```

#実行
```SampleService.java
package com.example.demo.service;

import java.io.BufferedReader;
import java.io.FileReader;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class SampleService {

	@Value("${inputData:test.csv}")
	private String fileName;

	public void execute() {

		try (FileReader fileReader = new FileReader(fileName); BufferedReader br = new BufferedReader(fileReader)) {

			String line;

			while ((line = br.readLine()) != null) {
				System.out.println(line);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

```



```
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
[32m :: Spring Boot :: [39m              [2m (v2.5.3)[0;39m

[2m2021-07-24 14:47:45.353[0;39m [32m INFO[0;39m [35m17620[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.example.demo.Demo4Application       [0;39m [2m:[0;39m Starting Demo4Application using Java 16.0.1 on LAPTOP-BQORFP6I with PID 17620 (C:\Users\kentaro\Desktop\workspaces\hackathon\demo-4\bin\main started by kentaro in C:\Users\kentaro\Desktop\workspaces\hackathon\demo-4)
[2m2021-07-24 14:47:45.357[0;39m [32m INFO[0;39m [35m17620[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.example.demo.Demo4Application       [0;39m [2m:[0;39m No active profile set, falling back to default profiles: default
[2m2021-07-24 14:47:46.025[0;39m [32m INFO[0;39m [35m17620[0;39m [2m---[0;39m [2m[           main][0;39m [36mtrationDelegate$BeanPostProcessorChecker[0;39m [2m:[0;39m Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$2ea57856] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2m2021-07-24 14:47:46.076[0;39m [32m INFO[0;39m [35m17620[0;39m [2m---[0;39m [2m[           main][0;39m [36m.w.s.a.s.AnnotationActionEndpointMapping[0;39m [2m:[0;39m Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
[2m2021-07-24 14:47:46.351[0;39m [32m INFO[0;39m [35m17620[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat initialized with port(s): 8080 (http)
[2m2021-07-24 14:47:46.363[0;39m [32m INFO[0;39m [35m17620[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.apache.catalina.core.StandardService  [0;39m [2m:[0;39m Starting service [Tomcat]
[2m2021-07-24 14:47:46.364[0;39m [32m INFO[0;39m [35m17620[0;39m [2m---[0;39m [2m[           main][0;39m [36morg.apache.catalina.core.StandardEngine [0;39m [2m:[0;39m Starting Servlet engine: [Apache Tomcat/9.0.50]
[2m2021-07-24 14:47:46.468[0;39m [32m INFO[0;39m [35m17620[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/]      [0;39m [2m:[0;39m Initializing Spring embedded WebApplicationContext
[2m2021-07-24 14:47:46.468[0;39m [32m INFO[0;39m [35m17620[0;39m [2m---[0;39m [2m[           main][0;39m [36mw.s.c.ServletWebServerApplicationContext[0;39m [2m:[0;39m Root WebApplicationContext: initialization completed in 1062 ms
[2m2021-07-24 14:47:46.905[0;39m [32m INFO[0;39m [35m17620[0;39m [2m---[0;39m [2m[           main][0;39m [36mo.s.b.w.embedded.tomcat.TomcatWebServer [0;39m [2m:[0;39m Tomcat started on port(s): 8080 (http) with context path ''
[2m2021-07-24 14:47:46.915[0;39m [32m INFO[0;39m [35m17620[0;39m [2m---[0;39m [2m[           main][0;39m [36mcom.example.demo.Demo4Application       [0;39m [2m:[0;39m Started Demo4Application in 1.94 seconds (JVM running for 2.697)
apple,banana,orange
Tokyo,Osaka,Kyoto
Baseball,Basketball,Soccer
```
いけてますね。
>FileReader fileReader = new FileReader(fileName);

FileReaderの引数には、srcディレクトリからの相対パスを指定してください。

おわりです。