Search code examples
intellij-ideavert.xvertx-verticle

How can I start a Vert.x Verticle in debug mode in IntelliJ


Very similar to this question, but not quite a duplicate (I think).

I have a Vert.x Verticle, which I run as described in the answer to the above question (i.e. by executing io.vertx.core.Launcher with relevant arguments, but I'm trying to start the same thing in debug mode.

Elsewhere in answers to the above question, I've seen people recommending adding a main() method to a Verticle and executing that in either run or debug mode, but I'd rather not add redundant code purely for this purpose.

The only option I can think of would be to start the Verticle as I am doing, but using the VM arguments to have it wait for a debugger, and then start a remote debug configuration in IntelliJ. That feels clumsy though; is there a better way?


Solution

  • You don't need a main() method.

    That's the minimal Verticle you need:

    public class MyVerticle extends AbstractVerticle {
        @Override
        public void start() {
            System.out.println("Verticle started");
        }
    }
    

    And that's how it should be launched: enter image description here

    After you've done that, just put a debug point in your verticle and start your application in debug mode.