Your Application’s run method is being called because you’re using an
EnvironmentCommand. EnvironmentCommand calls the run method on your
Application to set up the Environment it’s going to pass to you.

If you only need the Configuration (end not the Environment) make a
ConfiguredCommand, instead:

https://www.dropwizard.io/en/latest/manual/core.html#configured-commands

Ryan

On Mon, Mar 8, 2021 at 11:28 PM Aravindo Wingeier <[email protected]> wrote:

> Hi
>
> We have a Dropwizard application that does a lot of things in it's
> application.run() method. We moved a maintenance task into a command, so it
> can be run independently and without the full Jetty stack.
>
> Now I noticed that application.run() is still executed in
> EnvironmentCommand
> <https://github.com/dropwizard/dropwizard/blob/05bdecbe59366d4c747aa2f0256dcd768bd6b6e6/dropwizard-core/src/main/java/io/dropwizard/cli/EnvironmentCommand.java#L44>
> when running the the new command. What is the best way to avoid executing
> application.run() when running a command?
>
> I also doubt if using a Command is a good way to extract functionality? We
> still need the Configuration, so running a plain java application does not
> help as well.
>
> Best regards,
> Aravindo
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "dropwizard-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dropwizard-user/f7fdaf3b-8e38-49a9-96dd-dc8078f72c10n%40googlegroups.com
> <https://groups.google.com/d/msgid/dropwizard-user/f7fdaf3b-8e38-49a9-96dd-dc8078f72c10n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dropwizard-user/CAFVYhL-retysfpKdRzZcyg909uBvgfSirALhALQywNbzz4M-4w%40mail.gmail.com.

Reply via email to