How do I run a DropWizard / Jersey server locally without having to restart & repack to get asset file updates?

StackOverflow https://stackoverflow.com//questions/21004704

Question

I'm working on the client side of a project that is using DropWizard. Unfortunately what I'm experiencing is that for me to make a change to assets I have to stop the server, package the assets with maven, and then rerun the server or the assets will not be updated.

I tried adding dropwizard-configurable-assets-bundle but I'm still seeing the same behavior. Here's the service after adding it:

Service.java

public void initialize(strap<ServiceConfiguration> strap) {

    // Assets
    strap.addBundle(new ConfiguredAssetsBundle(
            "/dashboard/app/", "/dashboard/", "index.html"
    ));

    // Redirect /dashboard to /dashboard/
    strap.addBundle(new RedirectBundle(ImmutableMap.<String, String>builder()
            .put("/dashboard", "/dashboard/").build()));
}

I'm currently running mvn package && java -jar target/pack.jar server config.yml. I tried using Eclipse but I was having to restart it manually and it wasn't repackaging for me so it was slowing things down even further.

This whole process is reaaaally slowing me down and I'm hoping it's just my ignorance to the world that is Java.

Was it helpful?

Solution

If your assets are packaged under src/main/resources then they should just update automatically with Eclipse without a restart being required, so long as you're running the executable service main() from within the IDE.

You may need to check that your Maven plugin is set to "generate-resources" on changes but that is just the default setting so should be in place already.

What you're describing is definitely possible in Eclipse - I have personal experience of making resource changes (e.g. change and save an HTML asset) and then seeing an immediate update upon doing nothing more than a browser refresh.

OTHER TIPS

In my Intellij Idea, i am using JRebel plug-in for this purpose. JRebel also supports Eclipse.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top