Reputation: 157
I have a springboot project with default structure. I have an excel file under resources/data. My program need to load excel file and dump data into different tables from each sheet.
When I run from Eclipse, program loads excel file correctly and everything looks good. However, when I deploy the same App on Docker, it fails to read the File from resources.
Have anyone encountered this issues? How have you solved it?
Upvotes: 4
Views: 6670
Reputation: 42551
First of all try to check whether the Docker is a reason, or there is an issue with java code. Spring boot creates an artifact that can be run with just java -jar <your-spring-boot-artifact.jar>
If this doesn't run even without docker, then you should change the way you access Excel files from spring boot application (your java code): if the file is in resources folder, it should be packaged into the spring boot artifact.
In this case, you have to use getClass().getResourceAsStream()
to access the file, and not rely on java.io.File
API, because File API doesn't allow working with files inside a Jar, its not a regular filesystem.
Upvotes: 6