bootstrap.addCommand() takes an instance, but creating an instance means I don't get dependency injection - what's the right way?

35 views
Skip to first unread message

Benjamin Podszun

unread,
Nov 25, 2019, 3:10:23 AM11/25/19
to dropwizard-user
Hi.

New to dropwizard. I have a service that I want to use from both a resource (that should be fine) and from a command (that is my problem).
As the subject says: Given that the two overloads for bootstrap.addCommand() take instances, how do I make DI work for commands as well?

I don't have access to the service locator at that point. While I know how to access the service locator in run(), that doesn't help me to retroactively create/register (or inject into) my commands, right?

Am I missing something obvious?

Thanks.

rshukla21

unread,
Mar 3, 2020, 2:37:30 PM3/3/20
to dropwizard-user
Did you get your issue resolved, actually i am also new to dropwizard and my query is how run method of Command class gets executed bcz it is not getting executed automatically, would appreciate if you can suggest.

Thanks,
Ram
Reply all
Reply to author
Forward
0 new messages