Reputation: 47290
private static HttpHandler createHandler(HttpHandler servletHandler) {
return Handlers.path()
.addExactPath("/", resource(new PathResourceManager(Paths.get("src/main/resources/Index.html"), 100))
.setDirectoryListingEnabled(false)) // resolves index.html
.addPrefixPath(Context.getPath(), servletHandler)
.addPrefixPath("/static", resource(new PathResourceManager(Paths.get("src/main/resources/"))));
}
the above works from my IDE, but fails from the fatjar ?
Upvotes: 1
Views: 706
Reputation: 73548
When you're running it in the IDE, it's not in a jar and you can access resources normally on the filesystem with paths. When you're running inside a jar, you need to access the resources inside the jar file.
Use ClassPathResourceManager
for that. It works outside the jar too, as long as the resource is on the classpath.
Upvotes: 2