eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.26k stars 2.08k forks source link

Unable to disable file caching in 3.5.1 in intelliJ IDEA #2423

Open rprpx opened 6 years ago

rprpx commented 6 years ago

Static files in the JAR are not being "re-read" after they've been changed during development, while the app/server is running. The server has to be restarted after each change instead.

Inside my public static void main(String[] args) method, before any vert.x code, I have System.setProperty("vertx.disableFileCaching", "true");

Storing my static files on a file system path instead would be cumbersome due to this project's needs.

I have consulted Link #1514 and Link #1528, but I am not having success so far.

My development environment: Vert.x 3.5.1 JRE Oracle Java 1.8.0_171 IntelliJ IDEA 2018.1.2 Ubuntu 18.04

Here is the main method:

    public static void main(String[] args) {

        System.setProperty("vertx.disableFileCaching", "true");

        Vertx vertx = Vertx.vertx();
        vertx.deployVerticle(new VerticleOne(), asyncResult -> {
            if(asyncResult.failed()) {
                LOGGER.error("VerticleOne experienced an issue: " + asyncResult.cause());
            }
            else {
                LOGGER.info("VerticleOne deployed");
            }

        });

    }

Here is the start method of the Verticle:

    @Override
    public void start(Future<Void> startFuture) throws Exception {

        StaticHandler staticHandler = StaticHandler.create()
                .setWebRoot("net/rprpx/static")
                ;

        Router router = Router.router(vertx);
        router.route("/static/*").handler(staticHandler);

        HttpServer httpServer = vertx.createHttpServer()
                .requestHandler(router::accept)
                .listen(8080, asyncResult -> {

                    if(asyncResult.failed()) {
                        LOGGER.error("Could not start the HTTP server", 
                            asyncResult.cause());
                        startFuture.fail(asyncResult.cause());
                    }
                    else {
                        LOGGER.info("HTTP server now running on port " 
                            + asyncResult.result().actualPort());
                        startFuture.complete();
                    }

                });

    }

Thank you!

rprpx commented 6 years ago

I have discovered that upon running the same code with the Eclipse IDE (rather than intelliJ IDEA), all works as expected and the issue is not present.

I posted the issue here, in JetBrains' issue tracking system.

dxps commented 6 years ago

@rprpx My suggestion would be to use vertx-maven-plugin. See here an example that uses this plugin and includes your code.

petarov commented 5 years ago

I had the same issue and I just wanted to add that in order for static files to be re-read in IDEA, the project needs to be rebuilt, i.e., Build -> Build Module or Build Project. This can be done while the application is running in IDEA.

After rebuilding and refreshing the browser page, the static content changes are available.