pugnascotia / spring-react-boilerplate

An example of an isomorphic application using Java + Spring with React, React Router and Redux
MIT License
155 stars 51 forks source link

public/asset-manifest.json not found when running as a jar #15

Open agi76 opened 6 years ago

agi76 commented 6 years ago

Hey,

Have been playing around with your project and it's great. Really like the hot changes, makes development so fast.

Just one question, when trying to run the jar file using:

java -jar spring-react-boilerplate-1.0.0-SNAPSHOT.jar

I get:

FileNotFoundException: class path resource [public/asset-manifest.json] from com.pugnascotia.reactdemo.config.ViewConfig.getBundleName(ViewConfig.java:84)

Is there something I need to do?

Thanks!

agi76 commented 6 years ago

Answered my own question...

Switching to ClassPathResource solved the problem:

private String getBundleName() { TypeReference<HashMap<String,String>> typeRef = new TypeReference<HashMap<String,String>>() {}; Map<String, String> manifest = mapper.readValue(new ClassPathResource("public/asset-manifest.json").getInputStream(), typeRef); return "public/" + manifest.get("main.js"); }

pugnascotia commented 6 years ago

Thanks for the issue. I've reopened this as I'm surprised you had to change the code in order for the standalone JAR to work. When I get time I'll look into it myself.