I have 3 json files with combined size of 150mb and it has some data. In local , i stored it in resources folder and reading after application start up and writing to mongodb if the collection not exists.
When I deploy this to cloud, I am seeing null because files moved to BOOT-INF/classes inside a jar. I need suggestions on below queries.
How to write a common method which supports the file read local run vs cloud run ? As I am facing issues while running in cloud ? I tried as below
@Bean @Profile("cloud") public Resource[] getCloudResources() throws IOException { Resource[] resources = applicationContext.getResources("classpath*:*.json"); return resources; } @Bean @Profile("!cloud") public Resource[] getNonCloudResources() throws IOException { Resource[] resources = applicationContext.getResources("*.json"); return resources; }
It seems to be not the best practice to store these files in resources folder. What's the alternative approach according to 12 factors standard ? I am deploying in PCF
- Please suggest any other approach if you came across the similar use case.