1

I have a java maven project that reads a file and initializes a map from it. I have written it like this:

class CreateConstants {

    public static Map<EnumType, List<SomeType>> MAP_TO_FILL = new HashMap<EnumType, List<SomeType>>();    

    public static void fillConstantFromFile() {
        String filePath = "src/main/resources/file.json";
        //parse the json file and fill the MAP_TO_FILL map
    }

}

Now I build this project and add it as a maven dependency in another project.

From the second project if I call

CreateConstants.fillConstantFromFile() 

It fails with FileNotFoundException saying that it was not able to find the file in src/main/resources/file.json because the src/main/resources of the 2nd project does not have the file.

Is there a way I can initialize this map when the first project's jar itself gets created so that it does not have to read the file in the second project?

Or how can I make this file available from the second project so that it does not fail with FileNotFoundException?

Abhishek Chauhan
  • 309
  • 5
  • 15

0 Answers0