I have a Spring Boot application. The code that needs to access a file is under the /resources/templates directory.
The property from my application.properties file that I'm trying to read is given below:
pont.email.template.location=templates/mailTemplate.html
The above property that I'm trying to access via @Value in one of the @Component class is given below:
@Value("${pont.email.template.location}")
private String templateLocation;
Now, I have this code given below which takes the template location and tries to read it via BufferedReader.
BufferedReader reader = new BufferedReader(new FileReader(templateLocation));
Now, the value containing the file location is getting picked up properly by @Value from application.properties.
But the problem is that the application is not able to find templates/mailTemplate.html.
The error that I'm getting is given below:
java.io.FileNotFoundException: templates/mailTemplate.html (No such file or directory)
Note: I have checked that mailTemplate.html is present under the /resources/templates directory.
How to resolve this issue?
src/main/resources/templates?