问题
I am trying to use the functionality of dropwizard
http://dropwizard.codahale.com/manual/core/#commands
I have written a class which extends from ConfiguredCommand and i want to add/register this to the dropwizard service/environment. I can't find out how to add/run the new command from dropwizard.
回答1:
com.yammer.dropwizard.config.Bootstrap contains an addCommand method for adding ConfiguredCommand. You will get access to this object when you override initialize method in your service class, eg.
public void initialize (Bootstrap<T> configurationBootstrap) {
configurationBootstrap.addCommand(yourCommand);
}
来源:https://stackoverflow.com/questions/22106508/how-to-register-add-a-command-in-dropwizard