Skip to content
Advertisement

How to read a static file on Heroku deployment on Spring Boot

How can I solve this situation? I have a static JSON file on my src/main/resources and when I run the code, I use this JSON to create some data, but when I try to deploy on heroku I get this error, probably because they couldn’t find the FUNDOS.json file.

Does anyone have an idea on how to solve that?

Code

JavaScript

Error

JavaScript

Advertisement

Answer

For assets inside src/main/resources use getResourceAsStream or getResource.

Suppose your code is in a file named Foo.java,

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement